Part Number Hot Search : 
PQ05NF1 7C138 05000 CIR2262 P2301 EM92547B ER507 0LVEL
Product Description
Full Text Search
 

To Download W78IRD2A25DL Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  w78i rd2 d ata s heet 8- bit microcontroller publication release date : october 2 , 2006 - 1 - revision a 7 table of contents - 1. general description .......................................................................................................... 3 2. features .................................................................................................................................. 3 3. pin conf igurations ............................................................................................................. 4 4. pin description ..................................................................................................................... 5 5. functional descripti on .................................................................................................... 6 5. 1 ram ................................................................................................................................ 6 5.2 timers/counters .............................................................................................................. 6 5.3 clock ............................................................................................................................... 7 5.4 power management ........................................................................................................ 7 5.5 reduce emi emission ..................................................................................................... 7 5.6 reset ............................................................................................................................... 7 6. special function reg is ter .............................................................................................. 8 7. port 4 and base addr ess registers .......................................................................... 30 8. interrupts ............................................................................................................................ 32 8 .1 external interrupts 2 and 3 ............................................................................................ 32 8.2 interrupt priority ............................................................................................................. 32 9. programmable timers/ counters ................................................................................ 33 9.1 timer 0 and timer 1 ...................................................................................................... 33 9.2 timer/counter 2 ............................................................................................................ 35 10. enhanced full duplex serial port ............................................................................ 38 10.1 mode 0 ......................................................................................................................... 38 10.2 mode 1 ......................................................................................................................... 39 10.3 mode 2 ......................................................................................................................... 40 10.4 mode 3 ......................................................................................................................... 41 10.5 framing error detection ................................................................................................ 42 10.6 multi - processor communications ................................................................................. 42 11. programmable counter array (pca) ......................................................................... 44 11.1 pca capture mode ....................................................................................................... 47 11. 2 16- bit software timer comparator mode ...................................................................... 48 11.3 high speed output mode .............................................................................................. 48 11.4 pulse width modulator mode ........................................................................................ 49 11.5 watchdog timer ............................................................................................................ 50 12. hardware watchdog ti mer (one - time enabled with re set - out) ................... 51 13. dual dptr .............................................................................................................................. 51 14. timed - access protection ............................................................................................... 52
w78i rd2 - 2 - 15. in - system programming ( isp) mode ............................................................................. 54 16. h/w reboot mode (boo t from ldrom) ........................................................................ 58 17. option bits register ........................................................................................................ 59 18. electrical character istics ......................................................................................... 60 18.1 absolute maximum ratings .......................................................................................... 60 18.2 d.c. characteristics ...................................................................................................... 60 18.3 a.c. characteristics ....................................................................................................... 62 19. timing waveforms ............................................................................................................. 64 20. typical application circuits ......................................................................................... 66 20.1 external program memory and crystal ......................................................................... 66 20.2 expanded external data memory and oscillator .......................................................... 67 21. package dimensions .......................................................................................................... 68 22. application note ................................................................................................................ 70 22.1 in - system programming (isp) software examples ...................................................... 70 22.2 how to use programmable counter array .................................................................... 74 23. revision history ................................................................................................................. 75
w78i rd2 publication release date : october 2 , 2006 - 3 - revision a 7 1. general description the w78ird2 is an 8 - bit microcon troller which is pin - and instruction - set - compatible with the standard 80 c52. the w78ird2 contains a 64- k b flash eprom whose contents may be updated in - system by a loader program stored in an auxiliary, 4 - kb flash eprom . once the contents are confirmed, it can be protect ed for security. the w78ird2 also contains 256 bytes of on - chip ram ; 1 k b of auxiliary ram ; four 8 - bit , bi - directional and bit - addressable i/o ports; an additional 4 - bit port p4; three 16 - bit timer/counters; and a serial port. these peripher als are all supported by nine interrupt sources with 4 levels of priority . the w78ird2 has two power - reduction modes : idle mode and power - down mode, both of which are software - selectable. i dle mode turns off the processor clock but allows peripheral s to co ntinue operati ng, while p ower - down mode stops the crystal oscillator for minimum power consumption. power - down mode can be activated at any time and in any state without affecting the processor. 2. features ? 8 - bit cmos microcontroller ? pin - compatible with stand ard 80 c52 ? instruction - set compatible with 80c52 ? four 8 - bit i/o p orts ; port 0 has internal pull - up resisters enabled by software ? one extra 4 - bit i/o port with interrupt and chip - select function s ? three 16 - bit t imers ? programmable clock out ? pr ogrammable counte r array (pca) with pwm, capture, compare and watchdog functions ? 9 interrupt sources with 4 levels of priority ? f ull - duplex serial port with framing - error detection and automatic address recognition ? 64- kb, i n - s ystem - p rogrammable , flash eprom (ap flash epraom ) ? 4 - kb a uxiliary flash eprom for loader program (ld flash eprom ) ? 256- byte on - chip ram ? 1 - kb auxiliary ram, software - selectable ? software reset ? 12 clocks per machine cycle operation ( default). speed up to 2 0 m h z. ? 6 clocks per machine cycle operation s et by th e writer. speed up to 12 mhz. ? 2 dptr registers ? low emi ( inhibit ale) ? built - in power management with idle mode and power down mode ? code protection ? package s : lead free (rohs) dip 40: w78 i rd2 a 25dl lead free (rohs) plcc 44: w78 i rd2 a 25p l
w78i rd2 - 4 - 3. pin configurati ons vdd 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 39 40 34 35 36 37 38 30 31 32 33 26 27 28 29 21 22 23 24 25 p0.0, ad0 p0.1, ad1 p0.2, ad2 p0.3, ad3 p0.4, ad4 p0.5, ad5 p0.6, ad6 p0.7, ad7 ea ale psen p2.5, a13 p2.6, a14 p2.7, a15 p2.0, a8 p2.1, a9 p2.2, a10 p2.3, a11 p2.4, a12 t2, p1.0 40-pin dip p1.2 p1.3 p1.4 p1.5 p1.6 rxd, p3.0 txd, p3.1 p1.7 rst int0, p3.2 int1, p3.3 t0, p3.4 t1, p3.5 wr, p3.6 rd, p3.7 xtal1 xtal2 vss t2ex, p1.1 44-pin plcc 40 2 1 44 43 42 41 6 5 4 3 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 10 9 8 7 14 13 12 11 16 15 p1.5 p1.6 p1.7 rst rxd, p3.0 txd, p3.1 int0, p3.2 int1, p3.3 t0, p3.4 t1, p3.5 a d 3 , p 0 . 3 t 2 , p 1 . 0 p 1 . 2 v d d a d 2 , p 0 . 2 a d 1 , p 0 . 1 a d 0 , p 0 . 0 t 2 e x , p 1 . 1 p 1 . 3 p 1 . 4 x t a l 1 v s s p 2 . 4 , a 1 2 p 2 . 3 , a 1 1 p 2 . 2 , a 1 0 p 2 . 1 , a 9 p 2 . 0 , a 8 x t a l 2 p 3 . 7 , / r d p 3 . 6 , / w r p0.4, ad4 p0.5, ad5 p0.6, ad6 p0.7, ad7 ea ale psen p2.7, a15 p2.6, a14 p2.5, a13 p4.1 p 4 . 0 int2, p4.3 / i n t 3 , p 4 . 2
w78i rd2 publication release date : october 2 , 2006 - 5 - revision a 7 4. pin description symbol type * descriptions ea i external access enable: this pin forces the processor to execute instructions in external rom. the rom address and data are not presented on the bus i f the ea pin is high. psen o h program store enable: psen indicates external rom data is o n the port 0 address/data bus. if internal rom is access ed , no psen strobe signal is present on th is pin. ale o h address latch enable: ale is used to enable the address latch that separates the address from the data on port 0. ale runs at 1/6th of the oscillator frequency. rst i l reset: if this pin is set high for two machine cycles while the os cillator is running , the w78ird2 is reset. xtal1 i crystal 1: c rystal oscillator input or external clock input. xtal2 o crystal 2: c rystal oscillator output. v ss i ground: ground potential. v dd i power supply: supply voltage for operation. p0.0 ? p0.7 i/o d port 0: 8 - bit, bi - directional i/o port, the same as that of the standard 80 c52 port 0 has internal pull - up resisters enabled by software . p1.0 ? p1.7 i/o h port 1 : 8 - bit, bi - directional i/o port, the same as that of the standard 80 c52 . p2.0 ? p2 .7 i/o h port 2 : 8 - bit, bi - directional i/o port with internal pull - ups . this port also provides the upper address bits when access ing external memory. p3.0 ? p3.7 i/o h port 3 : 8 - bit, bi - directional i/o port, the same as that of the standard 80 c52 . p4. 0 ? p4.3 i/o h port 4: 4 - bit, bi - directional i/o port with chip - select functions . * note: type i: input, o: output, i/o: bi - directional, h: pull - high, l: pull - low, d: open drain
w78i rd2 - 6 - 5. functional descripti on the w78ird2 architecture consists of a core processo r that supports 111 different op - codes and references 64 k b of program space and 64 k b of data space. it is surrounded by various registers ; four general - purpose i/o ports ; one special - purpose , programmable , 4 - bit i/o port ; 256 bytes of ram ; 1 k b of auxili ary ram ( aux - ram ); three timer/counters ; a serial port ; and an internal 74373 latch and 74244 buffer which can be switched to port 2. this section introduces the ram, timers/counters, clock, power management, reduce emi emission, and reset. 5.1 ram the w78ird2 has two banks of ram: 256 bytes of ram and 1 k b of aux - ram. aux - ram is enabled by clearing bit 1 in the auxr register , and it is enabled after reset . different addresses in ram are addressed in different ways . ? ram 0 0 h ? 7fh can be addressed directly or indirectly , as in the 8051. the a ddress pointers are r0 and r1 of the selected bank . ? ram 80h ? ffh can only be addressed indirectly , as in the 8051. the a ddress pointers are r0 and r1 of the selected bank . ? aux - ram 0 0 h ? 3ffh is addressed indirectly in t he same way external data memory is accessed with the movx instruction. the a ddress pointer s are r0 and r1 of the selected bank and the dptr register. ? addresses higher than 3ffh are stored in external memory and are accessed indirectly with the movx inst ruction , as in the 8051. when aux - ram is enabled , the instruction "movx @ri" always access es aux - ram. when the w78ird2 is executing instructions from internal p rogram memory, access ing aux - ram does not affect p orts p0, p2, wr or rd . for e xample, anl auxr,#11111101b ; enable aux- ram mov dptr,#1234h mov a,#56h movx @dptr,a ; write 56h to address 1234h in external memory mov xramah,#02h ; only 2 lsb effective mov r0,#34h mov a,@r0 ; read aux- ram data at address 0234h 5.2 timers/counters the w78ird2 has three timers/counters called timer 0, timer 1, and timer 2. each t imer /counter consist s of two 8 - bit data registers : tl0 and th0 for timer 0, tl1 and th1 for timer 1, and tl2 and th2 for timer 2. the operations of timer 0 and timer 1 are similar to those in the w78 c52 , and these timers are controlled by t he tcon and tmod registers . timer 2 is controlled by the t2con register. like timers 0 and 1, timer 2 can operate as either an external event counter or an internal timer, depending on the setting of bit c/t2 in t2con. timer 2 has
w78i rd2 publication release date : october 2 , 2006 - 7 - revision a 7 three operating modes: capture, auto - reload, and baud rate generator. in capture or auto - reload mode, rcap2h and rcap2l are the reload / capture registers and the cloc k speed is the same as that of timers 0 and 1. 5.3 clock the w78ird2 is designed for either a crystal oscillator or an external clock. the w78ird2 incorporates a built - in crystal oscillator. to make the oscillator work, a crystal must be connected across pins xtal1 and xtal2 , and a load capacitor may be connected from each pin to ground . in addition , if the crystal frequency is higher than 2 0 mhz , a resistor should be connected between xtal1 and xtal2 to provide a dc bias. an external clock is connected to pin xtal1 , while p in xtal2 should be left dis connected. the xtal1 input is a cmos - type input, as required by the crystal oscillator. as a result, the logic - 1 voltage should be higher than 3.5 v . 5.4 power management the w78ird2 provides two modes, idle mode and po wer - down mode, to reduce power consumption. both modes are entered by software. the w78ird2 enters idle mode when the idl bit in the pcon register is set . in i dle mode, the internal clock for the processor stop s while t he internal clock for the peripherals and interrupt logic continue s to run . the w78ird2 leaves i dle mode when an interrupt or a reset occurs. the w78ird2 enters power - down mode when the pd bit in the pcon register is set . in power - down mode, all of the clocks are stopped, including the oscill ator. the w78ird2 leaves p ower - d own mode when there is a hardware reset or by external interrupt s int0 or int1 , if enabled. 5.5 reduce emi emission if the crystal frequency is less than 2 0 mhz, set bit 7 in the option register t o 0 to reduce emi emissions . please see option bits for more information . 5.6 reset the external reset signal is sampled at s5p2. to take effect, it must be held high for at least two machine cycles while the oscillator is running , as the w78ird2 has a special glitch - removal circuit that ignores glitches on the reset line. during reset, the ports are initialized to ffh, the stack pointer to 07h, and all of the other sfr to 00h , with two exceptions ? sbuf does not change, and bit 4 in pcon is not cleared.
w78i rd2 - 8 - 6. special func t ion register the following table identifies the special function registers (sfrs) in the w78ird2 , as well as each of their addresses and r eset v alues . f8 ch 00000000 ccap0h 00000000 ccap1h 00000000 ccap2h 00000000 ccap3h 00000000 ccap4h 00000000 f f f0 +b 00000000 chpenr 00000000 f7 e8 +p4 xxxx1111 cl 00000000 ccap0l 00000000 ccap1l 00000000 ccap2l 00000000 ccap3l 00000000 ccap4l 00000000 ef e0 +acc 00000000 e7 d8 ccon x0000000 cmod 00xxx000 ccapm0 x0000000 ccapm1 x0000000 ccapm2 x 0000000 ccapm3 x0000000 ccapm4 x0000000 ckcon xx000xx1 df d0 +psw 00000000 d7 c8 +t2con 00000000 t2mod xxxxxx00 rcap2l 00000000 rcap2h 00000000 tl2 00000000 th2 00000000 cf c0 xicon 00000000 xiconh 0xxx0xxx p4cona 00000000 p4conb 00000000 sfral 00000000 sfrah 00000000 sfrfd 00000000 sfrcn 00000000 c7 b8 +ip x0000000 saden 00000000 chpcon 000xx000 bf b0 +p3 00000000 p43al 00000000 p43ah 00000000 iph x0000000 b7 a8 +ie 00000000 saddr 00000000 p42al 00000000 p42ah 00000000 p4 csin 00000000 af a0 +p2 11111111 xramah 00000000 auxr1 xxxxx0x0 wdtrst 00000000 a7 98 +scon 00000000 sbuf xxxxxxxx p2eal 00000000 p2eah 00000000 9f 90 +p1 11111111 p41al 00000000 p41ah 00000000 97 88 +tcon 00000000 tmod 00000000 tl0 00000000 tl1 00000000 th0 00000000 th1 00000000 auxr 00000000 8f 80 +p0 11111111 sp 00000111 dpl 00000000 dph 00000000 p40al 00000000 p40ah 00000000 port 00000000 pcon 00110000 87 notes: 1. sfrs marked with a plus sign (+) are both byte - and bit - add ressable. 2. the text of sfr with bold type characters are extension function registers. the rest of this section explains each sfr, starting with the lowest address.
w78i rd2 publication release date : october 2 , 2006 - 9 - revision a 7 port 0 bit: 7 6 5 4 3 2 1 0 p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 mnemonic: p0 address: 80h port 0 is an open- drain , bi - directional i/o port after chip is reset . besides, i t has internal pull - up resisters enabled by setting p0up of popt (86h) to high. this port also provides a multiplexed , low - order address/data bus when the w78ir d2 accesses external memory. stack pointer bit: 7 6 5 4 3 2 1 0 sp.7 sp.6 sp.5 sp.4 sp.3 sp.2 sp.1 sp.0 mnemonic: sp address: 81h the stack pointer stores the ram address (scratchpad ram, not aux - ram) where the stack begins. i t always points to th e top of the stack. data pointer low bit: 7 6 5 4 3 2 1 0 dpl.7 dpl.6 dpl.5 dpl.4 dpl.3 dpl.2 dpl.1 dpl.0 mnemonic: dpl address: 82h this is the low byte of the standard - 8052 16- bit data pointer. data pointer high bit: 7 6 5 4 3 2 1 0 dph.7 dph. 6 dph.5 dph.4 dph.3 dph.2 dph.1 dph.0 mnemonic: dph address: 83h this is the high byte of the standard - 8052 16- bit data pointer. port 4.0 low - address comparator bit: 7 6 5 4 3 2 1 0 p40al.7 p40al.6 p40al.5 p40al.4 p40al.3 p40al.2 p40al.1 p40al.0 mnemonic: p40al address: 84h port 4.0 high - address comparator bit: 7 6 5 4 3 2 1 0 p40ah.7 p40ah.6 p40ah.5 p40ah.4 p40ah.3 p40ah.2 p40ah.1 p40ah.0 mnemonic: p40ah address: 85h port option register
w78i rd2 - 10 - bit: 7 6 5 4 3 2 1 0 - - - - - - - p0 up mnemoni c: popt address: 86h bit name function 1 ? 7 - reserve 0 p0 up 0: port 0 pins are open - drain . 1: port 0 pins are internally pulled - up. port 0 is structurally the same as port 2. power control bit: 7 6 5 4 3 2 1 0 sm o d smod0 - por gf1 gf0 pd idl mn emonic: pcon address: 87h bit name function 7 smod 1: d ouble the serial - port baud rate in serial port mode s 1, 2, and 3. 6 smod0 0: framing error detection disable. scon.7 acts as per the standard 8052 function. 1: framing error detection enable . sco n.7 indicates a frame error and acts as the fe (fe_1) flag. 5 - reserve d 4 pof thi s bit is set to 1 when a power - on reset has occurred . it can be cleared by sof tware. 3 gf1 g eneral - purpose flag. 2 gf0 g eneral - purpose flag. 1 pd set this bit to 1 to go into power down mode. 0 idl set this bit to 1 to go into idle mode. timer control bit: 7 6 5 4 3 2 1 0 tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 mnemonic: tcon address: 88h
w78i rd2 publication release date : october 2 , 2006 - 11 - revision a 7 bit name function 7 tf1 timer 1 overflow flag: this bit is set when timer 1 over flows. it is cleared automatically when the program does a timer 1 interrupt service routine. it can also be set or cleared by s oftware. 6 tr1 1: turn on timer 1 . 0: turn off timer 1. 5 tf0 timer 0 overflow flag: this bit is set when timer 0 overflows. i t is cleared automatically when the program does a timer 0 interrupt service routine. it can also be set or cleared by s oftware. 4 tr0 1: turn on timer 0. 0: turn off timer 0. 3 ie1 interrupt 1 edge detect: this bit is s et by the hardware when a falling - edge / low - level is detected on int1 . if int1 is edge - triggered, t his bit is cleared by the hardware when the interrupt service routine begins . otherwise , it follows the pin. 2 it1 interrupt 1 type control 1: interrupt 1 is trigg ered by a falling - edge on int1 . 0: interrupt 1 is triggered by a low - level on int1 . 1 ie0 interrupt 0 edge detect: this bit is s et by the hardware when a falling - edge / low - level is detected on int 0 . if int 0 is edge - triggered, t his bit is cleared by the hardware when the interrupt service routine begins . otherwise , it follows the pin. 0 it0 interrupt 0 type control 1: interrupt 0 is triggered by a falling - edge on int 0 . 0: interrupt 0 is trig gered by a low - level on int 0 . timer mode control bit: 7 6 5 4 3 2 1 0 gate t c/ m1 m0 gate t c/ m1 m0 mnemonic: tmod address: 89h bit name function 7 gate gating control: when this bit is set, timer /counter 1 is enabled only while the int1 pin is high and the tr 1 control bit is set. when clear ed, the int1 pin has no effect, and timer 1 is enabled whenever tr1 is set. 6 t c/ timer or counter select: when clear ed, t i mer 1 is incremented by the internal clock. when set, t imer 1 counts falling edges on the t 1 pin. 5 m1 timer 1 mode select bits: see below. 4 m0 timer 1 mode select bits: see below.
w78i rd2 - 12 - continued bit name function 3 gate gating control: when this bit is s et, timer /counter 0 is enabled only while the int0 pin is high and the tr 0 control bit is set. when clear ed, the int0 pin has no effect, and timer 0 is enabled whenever tr0 is set. 2 t c/ timer or counter selec t: when clear ed, t imer 0 is incremented by the internal clock. when set, t imer 0 counts falling edges on the t 0 pin. 1 m1 timer 0 mode select bits: see below. 0 m0 timer 0 mode select bits: see below. m1, m0: mode select bits: m1 m0 mode 0 0 mode 0: 8 048 timer, tlx serves as 5 - bit pre - scale. 0 1 mode 1: 16- bit timer/counter , no pre - scale. 1 0 mode 2: 8 - bit timer/counter with auto - reload from thx 1 1 mode 3: (timer 0) tl0 is an 8 - bit timer/counter controlled by the standard timer - 0 control bits. th0 is a n 8 - bit timer only controlled by timer - 1 control bits. (timer 1) timer/ c ounter 1 is stopped. timer 0 l sb bit: 7 6 5 4 3 2 1 0 tl0.7 tl0.6 tl0.5 tl0.4 tl0.3 tl0.2 tl0.1 tl0.0 mnemonic: tl0 address: 8ah tl0.7 - 0: timer 0 low byte timer 1 lsb bit: 7 6 5 4 3 2 1 0 tl1.7 tl1.6 tl1.5 tl1.4 tl1.3 tl1.2 tl1.1 tl1.0 mnemonic: tl1 address: 8bh tl1.7 - 0: timer 1 low byte timer 0 msb bit: 7 6 5 4 3 2 1 0 th0.7 th0.6 th0.5 th0.4 th0.3 th0.2 th0.1 th0.0 mnemonic: th0 address: 8ch th0.7 - 0: timer 0 high byte
w78i rd2 publication release date : october 2 , 2006 - 13 - revision a 7 timer 1 msb bit: 7 6 5 4 3 2 1 0 th1.7 th1.6 th1.5 th1.4 th1.3 th1.2 th1.1 th1.0 mnemonic: th1 address: 8dh th1.7 - 0: timer 1 high byte auxiliary register bit: 7 6 5 4 3 2 1 0 - - - - - - extram aleoff mnemonic: auxr address: 8e h bit name function 7 ~2 - reserve 1 extram 0 = enable aux - ram 1 = disable aux - ram 0 aleoff 0: ale expression is enabled. 1: ale expression is disabled. port 1 bit: 7 6 5 4 3 2 1 0 p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 mnemonic: p1 address: 90 h p1.7 - 0: general - purpose i nput/ o utput port. p ort - read instructions read the port pins , while read - modify - write instructions read the port latch. port 4.1 low address comparator bit: 7 6 5 4 3 2 1 0 p41al.7 p41al.6 p41al.5 p41al.4 p41al.3 p41al.2 p41al.1 p41al.0 mnemonic: p41al address: 94h port 4.1 high address comparator bit: 7 6 5 4 3 2 1 0 p41ah.7 p41ah.6 p41ah.5 p41ah.4 p41ah.3 p41ah.2 p41ah.1 p41ah.0 mnemonic: p41ah address: 95h
w78i rd2 - 14 - serial port control bit: 7 6 5 4 3 2 1 0 sm0/fe sm1 sm2 re n tb8 rb8 ti ri mnemonic: scon address: 98h bit name function 7 sm0/fe serial port, mode 0 (sm0) bit or framing - error (fe) flag: the smod0 bit in pcon sfr determines whether this bit acts as sm0 or as fe. sm0 is described with smi1 below. when used a s fe, this bit indicate s whether the stop bit is inva lid (fe=1) or valid (fe=0 ) . this bit must be manually cleared by software. 6 sm1 serial port , mode 1 (sm1) bit : mode: sm0 sm1 description length baud rate 0 0 0 synchronous 8 6(6t mode) /12 (12t mode) t clk 1 0 1 as ynchronous 10 variable 2 1 0 asynchronous 11 32/16(6t mode) or 64/32 (12t mode) t clk 3 1 1 asynchronous 11 variable 5 sm2 multi - pr ocessor communication. (modes 2 and 3) set this bit to enable the multi - processor communication feature. with this feature, ri is not activated if the ninth data bit received (rb8) is 0. (m ode 1 ) set this bit to 1 to keep ri de- activated if a valid stop bi t is not received. (m ode 0 ) sm2 controls the serial port clock. if clear , the serial port runs at 1/12 the oscillator. this is compatib le with the standard 8052. 4 ren receive enable: 1 = s erial reception is enabled 0 = serial reception is disabled 3 t b8 (modes 2 and 3) this is the ninth bit to be transmitted. this bit is set and cleared by software as desired. 2 rb8 (modes 2 and 3) t his is the ninth data bit that was received . (m ode 1) i f sm2 is 0, rb8 is the stop bit that was received. (m ode 0) n o fu nction. 1 ti transmit interrupt flag: this flag is set by the hardware at the end of the eighth bit in mode 0 or at the beginning of the stop bit in modes 1 ? 3 during serial transmission. this bit must be cleared by software. 0 ri receive interrupt flag : this flag is set by the hardware at the end of the eighth bit in mode 0 or halfway through the stop bit in modes 1 ? 3 during serial reception. however , sm2 restricts this bit. this bit can be cleared only by software.
w78i rd2 publication release date : october 2 , 2006 - 15 - revision a 7 serial data buffer bit: 7 6 5 4 3 2 1 0 sbuf.7 sbuf.6 sbuf.5 sbuf.4 sbuf.3 sbuf.2 sbuf.1 sbuf.0 mnemonic: sbuf address: 99h bit name function 7~0 sbuf serial port data is read from or written to this location. it actually consists of two separate , internal 8 - bit registers , the re ceive register and the transmit buffer. any read access reads data from the receive register , while write access writes to the transmit buffer. port 2 bit: 7 6 5 4 3 2 1 0 p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 mnemonic: p2 address: a0h ram high byte address bit: 7 6 5 4 3 2 1 0 0 0 0 0 0 0 xramah. 1 xramah. 0 mnemonic: xramah address: a1h the aux - ram high byte address auxiliary 1 register bit: 7 6 5 4 3 2 1 0 - - - - gf 2 0 - dps mnemonic: auxr1 address: a2h bit name function 7 ~4 - reserve d 3 gf2 g eneral purpose , user ? defined flag. 2 0 the bit cannot be written and is always read as 0 . 1 - reserve d 0 dps 0 = switch to dptr0 1 = switch to dptr1
w78i rd2 - 16 - watchdog timer reset register bit: 7 6 5 4 3 2 1 0 wdtrst.7 wdtrst.6 wdtrst.5 wdtrst.4 wd trst.3 wdtrst.2 wdtrst.1 wdtrst.0 mnemonic: wdtrst address: a6h interrupt enable bit: 7 6 5 4 3 2 1 0 ea ec et2 es et1 ex1 et0 ex0 mnemonic: ie address: a8h bit name function 7 ea global interrupt enable. enable/disable all interrupts except for pfi. 6 ec enable pca interrupt. 5 et2 enable timer 2 interrupt. 4 es enable serial port interrupt. 3 et1 enable timer 1 interrupt. 2 ex1 enable external interrupt int1 . 1 et0 enable timer 0 interrupt. 0 ex0 enable external interrupt int0 . slave address bit: 7 6 5 4 3 2 1 0 mnemonic: saddr address: a9h bit name function 7 ~0 saddr the saddr should be programmed to the given or broadcast address for serial port to which the slave processor is desig nated. port 4.2 low address comparator bit: 7 6 5 4 3 2 1 0 p42al.7 p42al.6 p42al.5 p42al.4 p42al.3 p42al.2 p42al.1 p42al.0 mnemonic: p42al address: a c h
w78i rd2 publication release date : october 2 , 2006 - 17 - revision a 7 port 4.2 high address comparator bit: 7 6 5 4 3 2 1 0 p42ah.7 p42ah.6 p42ah.5 p42ah.4 p42ah.3 p42ah.2 p42ah.1 p42ah.0 mnemonic: p42ah address: adh port 4 cs sign bit: 7 6 5 4 3 2 1 0 p4csin.7 p4csin.6 p4csin.5 p4csin.4 p4csin.3 p4csin.2 p4csin.1 p4csin.0 mnemonic: p4csin address: aeh port 3 bit: 7 6 5 4 3 2 1 0 p3.7 p32.6 p3.5 p32.4 p3 .3 p3.2 p3.1 p3.0 mnemonic: p3 address: b0h port 4.3 low address comparator bit: 7 6 5 4 3 2 1 0 p43al.7 p43al.6 p43al.5 p43al.4 p43al.3 p43al.2 p43al.1 p43al.0 mnemonic: p43al address: b4h port 4.3 high address comparator bit: 7 6 5 4 3 2 1 0 p43ah.7 p43ah.6 p43ah.5 p43ah.4 p43ah.3 p43ah.2 p43ah.1 p43ah.0 mnemonic: p43ah address: b5h interrupt priority high bit: 7 6 5 4 3 2 1 0 - ppch pt2h psh pt1h px1h pt0h px0h mnemonic: iph address: b8h
w78i rd2 - 18 - bit name function 7 - this bit is not i mplemented and is always read high. 6 ppch 1: s et the priority of the pca interrupt to the highest level. 5 pt2h 1: s et the priority of the timer 2 interrupt to the highest level. 4 psh 1: s et the priority of the serial port interrupt to the highest lev el. 3 pt1h 1: s et the priority of the timer 1 interrupt to the highest level. 2 px1h 1: s et the priority of external interrupt int1 to the highest level. 1 pt0h 1: s et the priority of the timer 0 interrupt to the highest level. 0 px0h 1 : s et the priority of external interrupt int0 to the highest level. interrupt priority bit: 7 6 5 4 3 2 1 0 - ppc pt2 ps pt1 px1 pt0 px0 mnemonic: ip address: b8h bit name function 7 - this bit is not implemented and is always r ead high. 6 ppc 1: s et the priority of the pca interrupt one level highe r . 5 pt2 1: s et the priority of the timer 2 interrupt one level highe r . 4 ps 1: s et the priority of the serial port interrupt one level highe r . 3 pt1 1: s et the priority of the tim er 1 interrupt one level highe r . 2 px1 1: s et the priority of external interrupt int1 one level highe r . 1 pt0 1: s et the priority of the timer 0 interrupt one level highe r . 0 px0 1: s et the priority of external interrupt int0 one level highe r . slave address mask enable bit: 7 6 5 4 3 2 1 0 mnemonic: saden address: b9h
w78i rd2 publication release date : october 2 , 2006 - 19 - revision a 7 bit name function 7~0 saden this register enables the automatic address recognition feature of the s erial port. when a bit in s aden is set to 1, the same bit in saddr is compared to the incoming serial data. when a bit in saden is set to 0, the same bit in saddr is a "don't care" value in the comparison. the serial port interrupt occurs only if all the saddr bits where saden is se t to 1 match the incoming serial data. on - chip programming control bit: 7 6 5 4 3 2 1 0 swrst/ reboot - - - - 0 fbootsl fprogen mnemonic: chpcon address: bfh bit name function 7 w: swreset r: reboot when fbootsl and fprogen are set to 1 , set this bit to 1 to force the microcontroller to reset to the initial condition , just like power - on reset. this action re - boot s the microcontroller and start s normal operation. r ead this bit to determine whether or not a hardware reboot is in progress . 6 ? 2 - reserve d 1 fbootsl program location select ion . this bit should be set before entering isp mode. 0: the loader program is in the 64 - kb ap flash ep rom. the 4 - kb ld flash ep rom is the destination for re - programming. 1: the loader program is in the 4 - kb memo ry bank. the 64- kb ap flash ep rom is the destination for re - programming. 0 fprogen flash eprom programming enable. 1: e nable in - system programming mode . in this mode, erase, program and read operations are achieve d during device enters idle state. 0: d is able in - system programming mode . the on - chip flash memory is read - only. chpcon has an unrestricted read access, however, the write access is protected by timed - access protection. see the section of timed - access protection for more information. external in terrupt control bit: 7 6 5 4 3 2 1 0 px3 ex3 ie3 it3 px2 ex2 ie2 it2 mnemonic: xicon address: c0h
w78i rd2 - 20 - bit name function 7 px3 1: s et the priority of external interrupt int3 one level highe r . 6 ex3 1: enable e xternal interrupt int3 . 5 ie3 interrupt int3 flag. this bit is set and cleared automatically by the hardware when the interrupt is detected and processed. 4 it3 1: int3 is falling - edge triggered 0: int3 is low - level t riggered 3 px2 1: s et the priority of external interrupt int2 one level highe r . 2 ex2 1: enable e xternal interrupt int2 . 1 ie2 interrupt int2 flag. this bit is set and cleared automatically by the hardware when the interrupt is detected and processed. 0 it2 1: int2 is falling - edge triggered 0: int2 is low - level triggered external interrupt high control bit: 7 6 5 4 3 2 1 0 pxh3 - - - pxh2 - - - mnemonic: xicon address: c 1 h bit name function 7 pxh3 1: s et the priority of external interrupt int3 to the highe st level. 6 - 4 - reserve d 3 pxh2 1: s et the priority of external interrupt int2 to the highe st level. 2 - 0 - reserve d port 4 c ontrol register a bit: 7 6 5 4 3 2 1 0 p41fun1 p41fun0 p41cmp1 p41cmp0 p40fun1 p40fun0 p40cmp1 p40cmp0 mnemonic: p4cona address: c2h
w78i rd2 publication release date : october 2 , 2006 - 21 - revision a 7 bit name function 7, 6 p41fun1 p41fun0 p4.1 function control bits , similar to p43fun1 and p43fun0 below . 5, 4 p41 cmp1 p41cmp0 p4.1 address - comparator length control bits , similar to p43cmp1 and p43cmp0 below . 3, 2 p40fun1 p40fun0 p4. 0 function control bits , similar to p43fun1 and p43fun0 below . 1, 0 p40cmp1 p40cmp0 p4. 0 address - comparator length control bits , simil ar to p43cmp1 and p43cmp0 below . port 4 control register b bit: 7 6 5 4 3 2 1 0 p43fun1 p43fun0 p43cmp1 p43cmp0 p42fun1 p42fun0 p42cmp1 p42cmp0 mnemonic: p4conb address: c3h bit name function 7, 6 p43fun1 p43fun0 00: mode 0. p4.3 is a general purpo se i/o port , like port 1. 01: mode 1. p4.3 is a r ead- s trobe signal for chip - select purpose s . the address range depends on sfr p43ah, p43al, p43cmp1 and p43cmp0. 10: mode 2. p4.3 is a w rite - s trobe signal for chip - select purpose s . the address range depends o n sfr p43ah, p43al, p43cmp1 and p43cmp0. 11: mode 3. p4.3 is a r ead/ w rite - s trobe signal for chip - select purpose s . the address range depends on sfr p43ah, p43al, p43cmp1, and p43cmp0. 5, 4 p43cmp1 p43cmp0 chip - select signal address comparison: 00: compare the full 16- bit address with p43ah and p43al. 01: compare the 15 msb of the 16 - bit address with p43ah and p43al. 10: compare the 14 msb of the 16 - bit address with p43ah and p43al. 11: compare the 8 msb of the 16 - bit address with p43ah. 3, 2 p42fun1 p42fun 0 p4. 2 function control bits , similar to p43fun1 and p43fun0 above . 1, 0 p42cmp1 p42cmp0 p4. 2 address - comparator length control bits , similar to p43cmp1 and p43cmp0 above .
w78i rd2 - 22 - f/w flash low address bit: 7 6 5 4 3 2 1 0 mnemonic: sfral address: c4h f/w flash low byte address f/w flash high address bit: 7 6 5 4 3 2 1 0 mnemonic: sfrah address: c5h f/w flash high byte address f/w flash data bit: 7 6 5 4 3 2 1 0 mnemonic: sfrfd address: c6h f/w flash data f/w flash control bit: 7 6 5 4 3 2 1 0 0 wfwin oe n ce n ctrl3 ctrl2 ctrl1 ctrl0 mnemonic: sfrcn address: c7h bit name function 7 - reserve d 6 wfwin on - chip flash eprom bank select for in - system programming. this bit should be defined by the loader program in isp mode . 0: 64 - k b flash eprom is the destination for re - programming. 1: 4 - k b flash eprom is the destination for re - programming. 5 oen flash eprom output enable. 4 cen flash eprom chip enable. 3 - 0 ctrl[3:0] f lash control signals timer 2 control bit: 7 6 5 4 3 2 1 0 tf2 exf2 rclk tclk exen2 tr2 c/t2 cp/rl2 mnemonic: t2con address: c8h
w78i rd2 publication release date : october 2 , 2006 - 23 - revision a 7 bit name function 7 tf2 timer 2 overflow flag: i f rclk and tclk are 0 , t his bit is set when timer 2 overflows or when the count is equal to the value in the capture regist er in down - count mode. this bit can also be set by s oftware , and it can only be cleared by software . 6 exf2 timer 2 external flag: when timer 2 is in either capture or auto - reload mode and dcen is 0, a negative transition on the t2ex pin (p1.1) and exen2= 1 set s this flag . this flag can also be set by software. once set, this flag generates a timer - 2 interrupt, if enabled, and it must be cleared by software. 5 rclk receive c lock flag: set this bit to force timer 2 into baud - rate generator mode when receivi ng data on the serial port in modes 1 or 3. 1 = timer 2 overflow is the time base. 0 = timer 1 overflow is the time base . 4 tclk transmit clock flag: set this bit to force timer 2 into baud - rate generator mode when transmitting data on the serial port in modes 1 or 3. 1 = timer 2 overflow is the time base. 0 = timer 1 overflow is the time base . 3 exen2 timer 2 external enable: if timer 2 is not in baud - rate generator mode (see rclk and tclk above), set t his bit to allow a negative transition on the t2ex p in to capture/reload timer 2 counter. 2 tr2 timer 2 run control: 1 = enable t imer 2. 0 = disable timer 2, which preserv es the current value in th2 and tl2. 1 c/t2 counter/timer select: 0 = timer 2 operates as a timer at a speed controlled by t2m (ckcon. 5) 1 = timer 2 counts negative edges on the t2ex pin. 0 cp/rl2 capture/reload select: if exen2 is set to 1, t his bit determines whether the capture or auto - reload function is activated. 0 = auto - reload when timer 2 overflows or a falling edge is detected on t2ex 1 = capture each falling edge is detected on t2ex if either rclk or tclk is set, this bit has no function , as t imer 2 runs in auto - reload mode . timer 2 mode bit: 7 6 5 4 3 2 1 0 - - - - - - t2oe dcen mnemonic: t2mod address: c9h
w78i rd2 - 24 - bit name function 7~2 - reserve d 1 t2oe timer 2 output enable. this bit ena bles/disables the timer 2 clock - out function. 0 dcen down count enable: setting dcen to 1 allows t2ex pin to control the direction that timer 2 counts in 16 - bit auto - reload mode. timer 2 capture low bit: 7 6 5 4 3 2 1 0 rcap2l.7 rcap2l.6 rcap2l.5 rcap2l.4 rcap2l.3 rcap2l.2 rcap2l.1 rcap2l.0 mnemonic: rcap2l address: cah rcap2l timer 2 capture lsb: in capture mode, rcap2l is used to capture the tl2 value. in auto - reload mode, rcap2l i s used as the lsb of the 16- bit reload value. timer 2 capture high bit: 7 6 5 4 3 2 1 0 rcap2h.7 rcap2h.6 rcap2h.5 rcap2h.4 rcap2h.3 rcap2h.2 rcap2h.1 rcap2h.0 mnemonic: rcap2h address: cbh rcap2 h timer 2 capture h sb: in capture mode, rcap2h is used t o capture the t h 2 value. in auto - reload mode, rcap2 h is used as the m sb of the 16- bit reload value. timer 2 register low bit: 7 6 5 4 3 2 1 0 tl2.7 tl2.6 tlh2.5 tl2.4 tl2.3 tl2.2 tl2.1 tl2.0 mnemonic: tl2 address: cch tl2 timer 2 lsb timer 2 regis ter high bit: 7 6 5 4 3 2 1 0 th2.7 th2.6 th2.5 th2.4 th2.3 th2.2 th2.1 th2.0 mnemonic: th2 address: cdh tl2 timer 2 msb program status word bit: 7 6 5 4 3 2 1 0 cy ac f0 rs1 rs0 ov f1 p mnemonic: psw address: d0h
w78i rd2 publication release date : october 2 , 2006 - 25 - revision a 7 bit name function 7 cy carry flag: set when an arithmetic operation results in a carry being generated from the alu. it is also used as the accumulator for bit operations. 6 ac auxiliary carry: set when the previous operation resulted in a carry from the high order nibble. 5 f 0 general ? purpose , user - defined flag 0 . 4 rs1 register bank select bits: see below. 3 rs0 register bank select bits: see below. 2 ov overflow flag: set when a carry was generated from the seventh bit but not from the eighth bit as a result of the previo us operation, or vice - versa. 1 f1 general ? purpose , user - defined flag 1 . 0 p parity flag: set and cleared by the hardware to indicate an odd or even number , respectively, of 1's in the accumulator. rs.1 - 0: register bank select bits: rs1 rs0 register ban k address 0 0 0 00- 07h 0 1 1 08- 0fh 1 0 2 10- 17h 1 1 3 18- 1fh pca counter control register bit: 7 6 5 4 3 2 1 0 cf cr - ccf4 ccf3 ccf2 ccf1 ccf0 mnemonic: ccon address: d8h pca counter mode register bit: 7 6 5 4 3 2 1 0 cidl wdte - - - cps1 cp s0 ecf mnemonic: cmod address: d9h pca module 0 register bit: 7 6 5 4 3 2 1 0 - ecom0 capp0 capn0 mat0 tog0 pwm0 eccf0 mnemonic: ccapm0 address: dah
w78i rd2 - 26 - pca module 1 register bit: 7 6 5 4 3 2 1 0 - ecom1 capp1 capn1 mat1 tog1 pwm1 eccf1 mnemonic: ccapm1 address: dbh pca module 2 register bit: 7 6 5 4 3 2 1 0 - ecom2 capp2 capn2 mat2 tog2 pwm2 eccf2 mnemonic: ccapm2 address: dch pca module 3 register bit: 7 6 5 4 3 2 1 0 - ecom3 capp3 capn3 mat3 tog3 pwm3 eccf3 mnemonic: ccapm3 address: ddh pca module 4 register bit: 7 6 5 4 3 2 1 0 - ecom4 capp4 capn4 mat4 tog4 pwm4 eccf4 mnemonic: ccapm4 address: deh clock control register bit: 7 6 5 4 3 2 1 0 - - t2m t1m t0m - - md mnemonic: ckcon address: dfh bit name function 7 - reserve d 6 - reserve d 5 t2m timer 2 clock select: 0 = d ivide - by - 6 clock 1 = d ivide - by - 12 clock this bit has no effect if option bit 3 is set to 1 to select 12 clocks / machine cycle. 4 t1m timer 1 clock select: 0 = d ivide - by - 6 clock 1 = d ivide - by - 12 clock this bit has no effect if option bit 3 is set to 1 to select 12 clocks / machine cycle. 3 t0m timer 0 clock select: 0 = d ivide - by - 6 clock 1 = d ivide - by - 12 clock this bit has no effect if option bit 3 is set to 1 to select 12 clocks / machine cycle.
w78i rd2 publication release date : october 2 , 2006 - 27 - revision a 7 continued bit name function 2 - reserve d 1 - reserve d 0 md stretch movx select bits: this bit is used to select the stretch value for the movx instruction , which e nables the microcontroller to access slower memory devices or peripherals transparently and without the need for external circuits. the rd or wr strobe and all internal timings are stretched by the selected interval. the default value is 1 cycle. for faster access, set the value to 0. ckcon has an unrestricted read access, however, the write access is protected by time d - a ccess protection. see the section of time d - access protection for more information. accumulator bit: 7 6 5 4 3 2 1 0 acc.7 acc.6 acc.5 acc.4 acc.3 acc.2 acc.1 acc.0 mnemonic: acc address: e0h acc.7 - 0: the a (or acc) register is th e standard 8052 accumulator. port 4 bit: 7 6 5 4 3 2 1 0 - - - - p4.3/int2 p4.2/int3 p4.1 p4.0 mnemonic: acc address: e8h p4.3 - 0 : port 4 is a bi - directional i/o port with internal pull - ups. bit name function 7 ? 4 - reserve d 3 p4.3 port 4 data bi t which outputs to pin p4.3 in mode 0, or external i nterrupt int2 . 2 p4.2 port 4 data bit which outputs to pin p4.2 in mode 0, or external i nterrupt int3 . 1 p4.1 port 4 data bit which outputs to pin p4.1 in mode 0. 0 p4.0 port 4 data bit which outputs to pin p4.0 in mode 0. pca counter low register bit: 7 6 5 4 3 2 1 0 cl.7 cl.6 cl.6 cl.4 cl.3 cl.2 cl.1 cl.0 mnemonic: cl address: e9h
w78i rd2 - 28 - pca module 0 compare/capture low register bit: 7 6 5 4 3 2 1 0 ccap0l.7 ccap0l. 6 ccap0l.5 ccap0l.4 ccap0l.3 ccap0l.2 ccap0l.1 ccap0l.0 mnemonic: ccap0l address: eah pca module 1 compare/capture low register bit: 7 6 5 4 3 2 1 0 ccap1l.7 ccap1l.6 ccap1l.5 ccap1l.4 ccap1l.3 ccap1l.2 ccap1l.1 ccap1l.0 mnemonic: ccap1l address: ebh pca module 2 compare/capture low register bit: 7 6 5 4 3 2 1 0 ccap2l.7 ccap2l.6 ccap2l.5 ccap2l.4 ccap2l.3 ccap2l.2 ccap2l.1 ccap2l.0 mnemonic: ccap2l address: ech pca module 3 compare/capture low register bit: 7 6 5 4 3 2 1 0 ccap3l.7 ccap3l.6 cca p3l.5 ccap3l.4 ccap3l.3 ccap3l.2 ccap3l.1 ccap3l.0 mnemonic: ccap3l address: edh pca module 4 compare/capture low register bit: 7 6 5 4 3 2 1 0 ccap4l.7 ccap4l.6 ccap4l.5 ccap4l.4 ccap4l.3 ccap4l.2 ccap4l.1 ccap4l.0 mnemonic: ccap4l address: eeh b re gister bit: 7 6 5 4 3 2 1 0 b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 mnemonic: b address: f0h b.7 - 0: the b register is the standard 8052 register that serves as a second accumulator. chip enable register bit: 7 6 5 4 3 2 1 0 mnemonic: chpenr add ress: f6h
w78i rd2 publication release date : october 2 , 2006 - 29 - revision a 7 pca counter high register bit: 7 6 5 4 3 2 1 0 ch.7 ch.6 ch.6 ch.4 ch.3 ch.2 ch.1 ch.0 mnemonic: ch address: f9h pca module 0 compare/capture high register bit: 7 6 5 4 3 2 1 0 ccap0h.7 ccap0h.6 ccap0h.5 ccap0h.4 ccap0h.3 ccap0h.2 ccap0 h.1 ccap0h.0 mnemonic: ccap0h address: fah pca module 1 compare/capture high register bit: 7 6 5 4 3 2 1 0 ccap1h.7 ccap1h.6 ccap1h.5 ccap1h.4 ccap1h.3 ccap1h.2 ccap1h.1 ccap1h.0 mnemonic: ccap1h address: fbh pca module 2 compare/capture high registe r bit: 7 6 5 4 3 2 1 0 ccap2h.7 ccap2h.6 ccap2h.5 ccap2h.4 ccap2h.3 ccap2h.2 ccap2h.1 ccap2h.0 mnemonic: ccap2h address: fch pca module 3 compare/capture high register bit: 7 6 5 4 3 2 1 0 ccap3h.7 ccap3h.6 ccap3h.5 ccap3h.4 ccap3h.3 ccap3h.2 ccap3h. 1 ccap3h.0 mnemonic: ccap3h address: fdh pca module 4 compare/capture high register bit: 7 6 5 4 3 2 1 0 ccap4h.7 ccap4h.6 ccap4h.5 ccap4h.4 ccap4h.3 ccap4h.2 ccap4h.1 ccap4h.0 mnemonic: ccap4h address: feh
w78i rd2 - 30 - 7. port 4 and base address r egisters port 4, address e8h, is a 4 - bit , multi - purpose , programmable i/o port. each bit can be configured individually , and registers p4cona and p4conb contain the control bits that select the mode of each pin. each pin has four operating modes. mode 0: b i - directional i/ o port , like p ort 1. p4.2 and p4.3 serve as external interrupt s int3 a nd int2 , if enabled. mode 1: r ead- strobe signals synchronized with the rd signal at specified addresses. these signals can be used as chi p - select signals for external peripherals. mode 2: w rite - strobe signals synchronized with the wr signal at specified addresses. these signals can be used as chip - select signals for external peripherals. mode 3: r ead/write - strobe signals s ynchronized with the rd or wr signal at specified addresses. these signals can be used as chip - select signals for external peripherals. in modes 1 ? 3, t he address range for chip - select signal s depends on the contents of registers p4xah and p4xal , which contain the high - order byte and low - order byte, respectively, of the 16- bit address comparator for p4.x . this is illustrated in the following schematic. address bus bit length selectable comparator register p4xal p4xah equal p4.x mux 4->1 p4 register p4.x read write data i/o rd_cs wr_cs rd/wr_cs p4xcmp0 p4xcmp1 p4xfun0 p4xfun1 p4xcsinv p4.x input data bus register pin figure 7 - 1
w78i rd2 publication release date : october 2 , 2006 - 31 - revision a 7 for example , the following program sets up p4.0 as a write - strobe signal for i/o port address es 1234h ? 1237h with positive polarity, while p4.1 ? p4.3 are used as general i/o ports. mov p40ah, #12h mov p40al, #34h ; base i/o address 1234h for p4.0 mov p4cona, #00001010b ; p4.0 is a write - strobe signal ; address line s a0 and a1 are masked. mov p4conb, #00h ; p4.1 ? p4.3 are general i/o port s mov p2econ, #10h ; set p40sinv to 1 to inver t the p4.0 write - strobe to positive polarity . then , any instruction movx @dptr, a ( where dptr is in 1234h ? 1237h) generate s a positive - polarity , write - strobe signal on pin p4.0 , while the instruction mov p4, #xx put s bit s 3 ? 1 of data #xx on pin s p4.3 ? p4.1.
w78i rd2 - 32 - 8. interrupt s this section provides more information about external interrupts int2 and int3 and provides an overview of interrupt priority levels and polling sequences. 8.1 external interrupts 2 and 3 the w78ird2 offers two additional external interrupts, int2 and int3 , similar to external interrupt s int0 and int1 in the standard 80c52. these interrupts are configured by the xicon (external interrupt control) register , which is not a standard register in the 80c52. i ts address is 0c0h. xicon is bit - addressable; f or example, "se t b 0c2h" sets the ex2 bit of xicon. 8.2 interrupt priority each interrupt has one of four priority levels in the w78ird2 , as shown below. four - level interrupt priority priority bits interrupt prior ity level iph.x ip.x 0 0 level 0 (lowest priority) 0 1 level 1 1 0 level 2 1 1 level 3 (highest priority) interrupts with the same priority level are polled in the sequence indicated below. nine - source interrupt information interrupt source polling sequence within priority level enable required settings interrupt type edge/level vector address external interrupt 0 0 (highest) ie.0 tcon.0 03h timer/counter 0 1 ie.1 - 0bh external interrupt 1 2 ie.2 tcon.2 13h timer/counter 1 3 ie.3 - 1bh program mable counter array 4 ie.6 - 33h serial port 5 ie.4 - 23h timer/counter 2 6 ie.5 - 2bh external interrupt 2 7 xicon.2 xicon.0 33h external interrupt 3 8 (lowest) xicon.6 xicon.3 3bh
w78i rd2 publication release date : october 2 , 2006 - 33 - revision a 7 9. programmable timers/ counters the w78ird2 has three 16 - bit programmabl e timer/counters. time - base selection the w78ird2 offers two speeds for the timer. t he timers can count at 1/12 of the clock, the same speed they have in the standard 8051 family. alternatively, t he timers can count at 1/ 6 of the clock , called turbo mode. the speed is controlled by bits t0m , t1m and t 2 m bits in ckcon. the default value is zero, which selects 1/12 of the clock. these 3 bits, t0m, t1m and t2m, have no effect if option bit 3 is set to 1 to select 12 clocks / machine cycle. 9.1 t imer 0 and timer 1 timer s 0 and 1 each have a 16 - bit timer/counter which consists of two eight - bit registers : timer 0 consists of th0 ( 8 msb) and tl0 (8 lsb), and timer 1 consists of th1 and tl1. the se timers/counters can be configured to operate either as timers, machine ? cy cle counters or counters based on external inputs. the "timer" or "counter" function itself is selected by the corresponding " t c/ " bit in the tmod r egister : bit 2 for timer 0 and bit 6 for timer 1. in addition , each t imer/ c ounter can operate in one of four possible modes , which are selected by bits m0 and m1 in tmod. the rest of this section explains the time - base for the timers and then introduces each mode. m ode 0 in mode 0, the timer/counter is a 13 - bit counter whose eight msb are in thx an d five lsb are the five lower bits in tlx. the upper three bits in tlx are ignored. because thx and tlx are read separately, the timer/counter act s like a n eight - bit counter with a five - bit, divide - by - 32 pre - scale . c ount ing is enabled only when trx is set and either gate = 0 or intx = 1. what the timer/counter counts depends on t c/ . when t c/ is set to 0, the timer/counter count s the negative edges of the clock according to the time - base selected by bits txm in ckcon. when t c/ is set to 1, it count s falling edges on t0 (p3.4 , for t imer 0 ) or t1 (p3.5 , for t imer 1 ) . when the 13 - bit count er reaches 1fffh , the next count rolls over the timer/counter to 0000h , and t he timer overflow flag tfx (in tcon) is set . i f enabled , an interrupt occur s .
w78i rd2 - 34 - 1/6 1/12 c/t = tmod.2 (c/t = tmod.6) t0m = ckcon.3 (t1m = ckcon.4) m1,m0 = tmod.1,tmod.0 (m1,m0 = tmod.5,tmod.4) interrupt t0 = p3.4 (t1 = p3.5) th0 (th1) tl0 (tl1) tf0 (tf1) tr0 = tcon.4 (tr1 = tcon.6) gate = tmod.3 (gate = tmod.7) int0 = p3.2 (int1 = p3.3) 7 0 tfx 4 7 0 timer 1 functions are shown in brackets 1 00 0 0 1 01 osc figure 9 - 1 timer/counter mode 0 & mode 1 m ode 1 mode 1 is similar to mode 0 , except that the timer/counter is 16- bit counter, not a 13- bit counter. a ll t he bits in thx and tlx are used. roll - over occurs when the timer moves from ffffh to 0000h. m ode 2 mode 2 is similar to mode 0, except that tlx acts like a n eight - bit count er and thx holds the auto - reload value for tlx . when the tlx register overflows from ffh to 00h, the timer overflow flag tfx bit ( in tcon ) is set , tlx is reloaded with the contents of thx, and the counting process continues. the reload operation does not affect the thx register. 1/6 1/12 t0m = ckcon.3 (t1m = ckcon.4) c/t = tmod.2 (c/t = tmod.6) interrupt t0 = p3.4 (t1 = p3.5) th0 (th1) tl0 (tl1) tf0 (tf1) tr0 = tcon.4 (tr1 = tcon.6) gate = tmod.3 (gate = tmod.7) int0 = p3.2 (int1 = p3.3) 7 0 tfx 7 0 timer 1 functions are shown in brackets 1 0 0 1 osc figure 9 - 2 timer/counter mode 2 m ode 3 mode 3 is used when an extra eight - bit timer is needed , and it has different effects on timer 0 and timer 1 .
w78i rd2 publication release date : october 2 , 2006 - 35 - revision a 7 timer 0 separates tl0 and th0 into two separate eight - bit count registers . tl0 uses the timer 0 contro l bits t c/ , gate, tr0, int0 and tf0 and can count clock cycles (clock / 12 or clock / 6 ) or falling edges on pin t0. meanwhile, th0 takes over tr1 and tf1 from timer 1 and can count clock cycle s (clock / 12 or clock / 6 ). m ode 3 s imply freezes timer 1, which provides a way to turn it on and off . when timer 0 is in mode 3, timer 1 can still be used in modes 0, 1 and 2, but its flexibility is limited . timer 1 can still be used as a timer / counter (or a baud - rate generator for the se rial port) and retains the use of gate and int1 pin , but it no longer has control over the overflow flag tf1 and enable bit tr1. 1/6 1/12 t0m = ckcon.3 interrupt c/t = tmod.2 t0 = p3.4 th0 tl0 tr0 = tcon.4 gate = tmod.3 tr1 = tcon.6 int0 = p3.2 7 0 tf1 7 0 interrupt tf0 1 0 0 1 osc figure 9 - 3 timer/counter 0 mode 3 9.2 t imer / c ounter 2 timer 2 is a 16 - bit up/down counter equipped with a capture/reload capability . it is configured by the t2mod register and controlled by the t2con register. as with timer s 0 and 1, timer 2 can count clock cycles (fosc / 12 or fosc / 6 ) or the external t2 pin , as selec ted by t2 c/ , and there are four operating modes, each discussed below. c apture m ode c apture mode is enabled by setting the rl2 cp/ bit in the t2con register. in capture mode, timer 2 serves as a 16 - bit up - counter. when the counter ro lls over from ffffh to 0000h, the tf2 bit is set, and, if enabled, an interrupt is generated . if the exen2 bit is set, then a negative transition on the t2ex pin captures the value in tl2 and th2 register s in the rcap2l and rcap2h registers. this action al so causes the exf2 bit in t2con to be set, which may also generate an interrupt.
w78i rd2 - 36 - rclk+tclk=0, rl2 cp/ =t2con.0=1 1/6 1/12 t2m = ckcon.5 c/t2 = t2con.1 t2con.7 t2 = p1.0 t2con.6 tr2 = t2con.2 t2ex = p1.1 exen2 = t2con.3 exf2 timer 2 interrupt tf2 th2 tl2 rcap2h rcap2l 1 0 0 1 osc figure 9 - 4 16- bit capture mode a uto - reload m ode, c ounting up this mode is enabled by clearing the rl2 cp/ bit in t2con and the dcen bit in t2mod. in this mode, timer 2 is a 16 - bit up - counter. when the counter rolls over from ffffh to 0000h , the contents of rcap2l and rcap2h are automatically reloaded into tl2 and th2 , and the timer overflow bit tf2 is set . if the exen2 bit is set, then a negative transition of t2ex pin also cause s a reload , which also sets the exf2 bit in t2con. rclk+tclk=0, rl2 cp/ =t2con.0=0, dcen=0 1/6 1/12 t2m = ckcon.5 c/t2 = t2con.1 t2con.7 t2 = p1.0 t2con.6 tr2 = t2con.2 t2ex = p1.1 exen2 = t2con.3 exf2 timer 2 interrupt tf2 th2 tl2 rcap2 h rcap2l 1 0 0 1 osc figure 9 - 5 16- bit auto - reload mode, counting up a uto - reload m ode, c ounting up /d own this mode is enabled when the rl2 cp/ bit in t2con is clear and the dcen bit in t2mod is set. in this mode, timer 2 is an up/down - c ounter whose direction is controlled by the t2ex pin (1 = up, 0 = down) . when timer 2 overflow s while counting up , the counter is reloaded by rcap2l and rcap2h. when timer 2 is counting down, the counter is reloaded with ffffh when timer 2 is equal to rcap 2l and rcap2h. in either case, the timer overflow bit tf2 is set, and the exf2 bit is toggled, though exf2 can not generate an interrupt in this mode.
w78i rd2 publication release date : october 2 , 2006 - 37 - revision a 7 rclk+tclk=0, rl2 cp/ =t2con.0=0, dc en= 1 c/t = t2con.1 1/6 1/12 t2m = ckcon.5 down counting reload value t2con.7 up counting reload value t2 = p1.0 t2con.6 tr2 = t2con.2 t2ex = p1.1 exf2 timer 2 interrupt tf2 th2 tl2 rcap2h rcap2l 1 0 0 1 0ffh 0ffh osc figure 9 - 6 16- bit auto - reload up/down counter b aud r ate g enerator m ode b aud- rate generator mode is enabled by setting either the rclk or tclk bits in t2con register. i n baud- rate generator mode , timer 2 is a 16 - bit up- counter that automatically reloads when it overflows, but this overflow does not set the timer overflow bit tf2. if exen2 is set, then a negative transition on the t2ex pin set s exf2 bit in t2con and , if enabled, generates an interrupt request. rclk+tclk= 1 c/t = t2con.1 t2 = p1.0 t2con.6 tr2 = t2con.2 t2ex = p1.1 exen2 = t2con.3 exf2 timer 2 overflow timer 2 interrupt th2 tl2 rcap2h rcap2l 0 1 osc figure 9 - 7 baud rate generator mode
w78i rd2 - 38 - 10. enhanced full duplex serial port the w78ird2 s erial port is a full - duplex port , and t he w78ird2 provides additional features such as f rame - e rror d etection and a utomatic a ddress r ecognition. the serial port runs in one of four operating modes. serial ports modes sm1 sm0 mode type baud clock frame size start bit stop bit 9th bit function 0 0 0 synch. 12 tclks 8 bits no no none 0 1 1 asynch. timer 1 or 2 10 bits 1 1 none 1 0 2 asy nch. 32 or 64 tclks 11 bits 1 1 0, 1 1 1 3 asynch. timer 1 or 2 11 bits 1 1 0, 1 in s ynchronous mode (mode 0), the w78ird2 generates the clock and operates in a half - duplex mode. in asynchronous mode s (modes 1 ? 3) , full - duplex operation is available so that the serial port can simultaneously transmit and receive data. in any mode, register sbuf functions as both t he transmi t register and the receive buffer. a ny write to sbuf writes to the transmit register, while any read from sbuf reads from the receive buffer. the rest of this section discusses each operating mode and then discusses frame - error detection and automatic address recognition. 10.1 mode 0 mode 0 is a half - duplex, synchronous mode . rxd transmits and receives s erial data , and t x d transmit s the shif t clock. the t x d clock is provided by the w78ird2 . eight bits are transmitted or received per frame , lsb first. the baud rate is fixed at 1/12 of the oscillator frequency. the functional block diagram is shown below. sbuf transmit shift register receive shift register tx shift parout internal data bus internal data bus rxd p3.0 alternate output function txd p3.1 alternate output function rxd p3.0 alternate iutput function serial port interrupt write to sbuf tx start sout ti ri ren parin load clock read sbuf sbuf tx clock ri serial controlle shift clock rx clock load sbuf rx start rx shift clock sin 12 osc figure 10- 1 serial port mode 0
w78i rd2 publication release date : october 2 , 2006 - 39 - revision a 7 as mentioned before, d ata enters and leaves the s erial port on rxd. t x d line provides the shift clock , which shift s data into and out of the w78ird2 and the device at the other end of the line. any instruction that write s to sbuf start s the transmission. the shift clock is activated , and the data is shifted out on the rxd pin until all eight bits are transmitted. if sm2 is set to 1, the data appears on rxd one clock period before the falling edge on txd , and t he txd clock then remains low for two clock periods before go ing high again. if sm2 is set to 0, the data appears on rxd three clock periods before the falling edge on txd , and the txd clock then remains low for six clock periods before go ing hig h again. this ensures that the receiving device can clock rxd data on the rising edge o f txd or when the txd clock is low. finally, t he ti flag is set high in c1 once the last bit has been transmitted . the serial port receive s data when ren is 1 and ri is zero. the txd clock is activated , and the serial port latch es data on the rising edge of the shift clock. as a result, t he external device should present data on the falling edge of txd . this process continues until all eight bits have been received. then, after the last rising edge on txd , t he ri flag is set high in c1 , which stop s reception until ri is cleared by the software. 10.2 mode 1 mode 1 is a full ? duplex , asynchronous mode . serial communication frames are made up of ten bits transmitted on txd and rece ived on rxd. the ten bits consist of a start bit (0), eight data bits (lsb first), and a stop bit (1). when the w78ird2 receives data , the stop bit goes into rb8 in scon. the baud rate is either 1/16 or 1/32 of the timer 1 overflow , which can be set to a v ariety of reload values. (the 1/16 or 1/32 factor is determined by the smod bit in pcon sfr .) the functional diagram is shown below. sbuf rb8 transmit shift register receive shift register tx shift parout d8 internal data bus internal data bus txd rxd serial port interrupt smod = tclk rclk sample write to sbuf tx start sout 0 1 0 1 ti 1 0 parin stop start load clock read sbuf timer 2 overflow timer 1 overflow tx clock ri serial controller rx clock load sbuf rx start rx shift 2 16 1-to-0 detector bit detector 16 clock sin figure 10- 2 serial port mode 1
w78i rd2 - 40 - transmission begins when d ata is written to sbuf but is synchronized with the roll - over of timer 1 ( divided by 16 or 32, as configured ) and not the write signal. the w78ird2 waits until the next roll - over of timer 1 ( divided by 16 or 32 ) before t he data is put on txd . the next bit is placed on txd after the next rollover. after all eight bits of data are transmitted, the stop bit is transmitted. finally, t he ti flag is set , at the tenth rollover after the write signal . reception is enabled only if ren is high . t he w78ird2 samples th e rxd line at a rate of 16 times the selected baud rate , looking for a falling edge . when a falling edge is detected on the rxd pin , timer 1 ( divided by 16 or 32 ) is immediately reset to align the bit boundaries better, and t he serial port starts receiving data. the 16 states of the counter effectively divide the time into 16 slices , and bit detection is done on a best - of - three basis using the eighth , ninth and tenth states. if the start bit is invalid (1) , reception is aborted , and t he serial port resumes look ing for a falling edge on rxd. if the start bit is valid, the eight data bits are shifted in . then, if (1) ri = 0 and (2) sm2 = 0 or the stop bit = 1 , the stop bit is put in to rb8, the data is put in sbuf, and ri is set. otherwise , the received frame m ay be lost. in the middle of the stop bit, the w78ird2 resumes looking for falling edges on rxd. 10.3 mode 2 m ode 2 is a full - duplex, asynchronous mode . serial communication frames are made up of eleven bits transmitted on txd and received on rxd. the eleven bi ts consist of a start bit (0), eight data bits (lsb first), a programmable ninth bit (tb8) and a stop bit ( 1 ). the ninth bit is read into and transmitted from rb8. the baud rate is either 1/32 or 1/64 of the oscillator frequency , and the 1/32 or 1/64 facto r is determined by the smod bit in pcon sfr. the functional diagram is shown below. sbuf rb8 transmit shift register receive shift register tx shift parout d8 internal data bus internal data bus txd rxd serial port interrupt smod = sample write to sbuf tx start sout 0 1 ti parin stop start load clock read sbuf tx clock ri serial controller rx clock load sbuf rx start rx shift 2 16 1-to-0 detector bit detector 16 clock sin d8 tb8 1/2 fosc figure 10- 3 serial port mode 2 transmission begins when data is written to sbuf but is synchronized with the roll - over of the counter ( divided by 32 or 64, as configured ) and not the write signal. the w78ird2 waits until the next roll - over
w78i rd2 publication release date : october 2 , 2006 - 41 - revision a 7 of the counter ( divided by 32 or 64 ) before the data is put on txd. the next bit is placed on txd after the next rollover . after all nine bits of data are transmitted, the stop bit is transmitted. finally, t he ti flag is set , at the eleventh rollover after the write signal . reception is enabled only if ren is high. the w78ird2 sampl es the rxd line at a rate of 16 times the s elected baud rate , looking for a falling edge . when a falling edge is detected on the rxd pin , the counter ( divided by 32 or 64 ) is immediately reset to align the bit boundaries better, and the serial port starts receiving data . the 16 states of the counte r effectively divide the time into 16 slices , and bit detection is done on a best - of - three basis using the eighth , ninth and tenth states. if the start bit is invalid (1), reception is aborted , and t he serial port resumes look ing for a falling edge on rxd. if the start bit is valid , the rest of the bits are shifted in. then, if (1) ri = 0 and (2) either sm2 = 0 or the received 9th bit = 1 , the ninth bit is put in to rb8, the data is put in sbuf, and ri is set. otherwise , the received frame may be lost. in th e middle of the stop bit, the w78ird2 resumes looking for falling edges on rxd . 10.4 mode 3 mode 3 is similar to m ode 2 in all respects, except that the baud rate is programmable the same way it is programmable in mode 1 . the functional diagram is shown below. sbuf rb8 transmit shift register receive shift register tx shift parout d8 internal data bus internal data bus txd rxd serial port interrupt smod = tclk rclk sample write to sbuf tx start sout 0 1 0 1 ti 1 0 parin stop start load clock read sbuf timer 2 overflow timer 1 overflow tx clock ri serial controller rx clock load sbuf rx start rx shift 2 16 1-to-0 detector bit detector 16 clock sin d8 tb8 figure 10- 4 serial port mode 3
w78i rd2 - 42 - 10.5 framing error detection a f rame e rror occurs when a valid stop bit is not detected. this could indicate incorrect serial data communication. typically , the fr ame error is due to noise or contention on the serial communication line. the w78ird2 has the ability to detect framing errors and set a flag which can be checked by software. the f rame e rror fe bit is located in scon.7. this bit is normally used as sm0 in the standard 8051 family. however, in the w78ird2 it serves a dual function and is called sm0/fe. there are actually two separate flags, one for sm0 and the other for fe. the flag that is actually accessed as scon.7 is determined by smod0 (pcon.6) bit. wh en smod0 is set to 1, then the fe flag is accessed . when smod0 is set to 0, then the sm0 flag is accessed . the fe bit is set to 1 by the hardware but must be cleared by software. once fe is set, any frames received afterwards, even those without any error s , do not clear the fe flag. the flag has to be cleared by software. note that smod0 must be set to 1 while reading or writing to fe. 10.6 multi -p rocessor communications multi - processor communication makes use of the 9th data bit in modes 2 and 3. in the w78ird2 , the ri flag is set only if the received byte corresponds to the given or broadcast address. this hardware feature eliminates the software overhead required in checking every received address and greatly simplifies the software programmer task. in m ulti - p rocessor communication mode, the address bytes are distinguished from the data bytes by the 9th bit , which is set high for address bytes . when the master processor wants to transmit a block of data to one of the slaves, it first sends out the address of th e target slave (or slaves). all the slave processors should have their sm2 bit set high when waiting for an address byte. this ensures that they are interrupted only by the reception of a n address byte. the a utomatic address recognition feature ensures tha t only the addressed slave is actually interrupted because t he address comparison is done by the hardware , not the software. the addressed slave clears the sm2 bit, thereby clearing the way to receive data bytes. with sm2 = 0, the slave is interrupted on t he reception of every single complete frame of data. the unaddressed slaves are not affected, as they are still waiting for their address. the master processor can selectively communicate with groups of slaves by using the given address. all the slaves can be addressed together using the broadcast address. the addresses for each slave are defined in the saddr and saden registers . the slave address is an eight - bit value specified in the saddr sfr. the saden sfr is actually a mask for the byte value in saddr. if a bit position in saden is 0, then the corresponding bit position in saddr is don't care. only those bit positions in saddr whose corresponding bits in saden are 1 are used to obtain the given address. this gives the user flexibility to address multipl e slaves without changing the slave address in saddr. the following example shows how the user can define the given address to address different slaves.
w78i rd2 publication release date : october 2 , 2006 - 43 - revision a 7 slave 1: saddr 1010 0100 saden 1111 1010 given 1010 0x0x slave 2: saddr 1010 0111 saden 1111 1001 given 1010 0xx1 the given address for slave s 1 and 2 differ in the lsb. for slave 1, it is a don't - care, while for slave 2 it is 1. thus to communicate only with slave 1, the master must send an address with lsb = 0 (1010 0000). similarly the bit 1 po sition is 0 for slave 1 and don't care for slave 2. hence to communicate only with slave 2 the master has to transmit an address with bit 1 = 1 (1010 0011). if the master wishes to communicate with both slaves simultaneously, then the address must have bit 0 = 1 and bit 1 = 0. the bit 3 position is don't - care for both the slaves. this allows two different addresses to select both slaves (1010 0001 and 1010 0101). the master can communicate with all the slaves simultaneously with the broadcast address. this address is formed from the logical or of the saddr and saden sfrs. the zeros in the result are defined as don't cares . in most cases , the broadcast address is ffh. in the previous example , the broadcast address is (1111111x) for slave 1 and (11111111) for slave 2. the saddr and saden sfrs are located at address es a9h and b9h , respectively. on reset, these registers are initialized to 00h. this results in given address and broadcast address being set as xxxx xxxx(i.e. all bits don't care). this effectively r emoves the m ulti - processor communications feature, since any selectivity is disabled.
w78i rd2 - 44 - 11. programmable counter array (pca) the pca is a special 16 - bit t imer that has five 16 - bit capture/compare modules associated with it. each module can be programmed to oper ate in one of four modes: rising and/or falling edge capture, software timer, high - speed output, or pulse width modulator. each module has a pin associate d with it in port 1. m odule 0 is connected to p1.3 (cex0), module 1 to p1.4 (cex1), and so on . pca timer/counter module0 module1 module2 module3 module4 p1.3/cex0 p1.4/cex1 p1.5/cex2 p1.6/cex3 p1.7/cex4 time base for pca modules module functions: 16-bit capture 16-bit timer/compare 16-bit high speed output 8-bit pwm watchdog timer (module 4 only) ch cl 16-bit up-counter figure 11- 1 programmable counter array (pca) each module has a special function register ccapm n , where n is the same number as the module (ccapm0 for module0, ccapm1 for module1 , etc. ). ccapm n contains the bits that control the mode of each module. ccapmn : pca module compare/capture register ccapm0(dah) , ccapm1(dbh) , ccapm2(dch) , ccapm 3(ddh), ccapm 4(deh) bit name function 7 - reserved 6 ecomn enable comparator. ecomn = 1 enables th e comparator function 5 cappn capture positive. cappn = 1 enables positive - edge capture. 4 capnn capture negative. capnn = 1 enables negative - edge capture. 3 matn match. when matn = 1 a match of the pca counter with this module?s compare/capture registe r causes the ccf n bit in ccon to be set and, if eccfn is set , generating an interrupt. 2 togn toggle. when togn = 1 a match of the pca counter with this module?s compare/capture register causes the cexn bit to toggle. 1 pwmn pulse width modulation mode. pwmn = 1 enables the cexn bit to be used for pulse - width modulated output. 0 eccfn enable ccf interrupt. enables the compare/capture flag ccfn in the ccon register to generate an interrupt.
w78i rd2 publication release date : october 2 , 2006 - 45 - revision a 7 module function ecom n cappn capnn matn togn pwmn eccfn no op eration 0 0 0 0 0 0 0 16- bit capture by a positive edge trigger on cexn x 1 0 0 0 0 x 16- bit capture by a negative trigger on cexn x 0 1 0 0 0 x 16- bit capture by a transition on cexn x 1 1 0 0 0 x 16- bit software timer 1 0 0 1 0 0 x 16- bit high speed output 1 0 0 1 1 0 x 8 - bit pwm 1 0 0 0 0 1 0 watchdog timer (only in module4) 1 0 0 1 x 0 x pca module modes (ccapmn register) p wm enables pulse width modulation. t he tog bit causes the output cex n to toggle when there is a match between the pca counte r and the module?s compare/capture register. the match bit mat cause s the ccf bit in the ccon register to be set when there is a match between the pca counter and the module?s compare/capture register , and the eccf bit enables the ccf flag to generate an i nterrupt . the bits capp and capn determine whether positive and negative edge s, respectively, are captured . the bit ecom enables the comparator function. the pca timer is the common time - base for all five modules and can be programmed to select the appropr iate timer source. the default value is 12 clocks ( 12 t) per machine cycle , and 6t can also be selected by a bit in the options registers . the actual timer is then determined by the cps1 and cps2 bits in the cmod sfr , as follows: cps1 cps0 pca timer count s ource for 12t pca timer count sour ce for 6t 0 0 oscillator frequency / 12 oscillator frequency / 6 0 1 oscillator frequency / 4 oscillator frequency / 2 1 0 timer 0 overflow timer 0 overflow 1 1 external input at eci pin external input at eci pin
w78i rd2 - 46 - cmod(d8h) : pca counter mode register bit name function 7 cild counter idle control: cild = 0 programs the pca counter to continue functioning in idle mode ; cild = 1 programs it to stop in idle mode . 6 wdte watchdog timer enable: wdte = 0 disables the watchdog timer function i n pca module 4. wdte = 1 enables it. 5 - reserved 4 - reserved 3 - reserved 2 cps1 pca count pulse select bit 1 1 cps0 pca count pulse select bit 0 0 ecf pca enable counter overflow interrupt: ecf = 1 enables cf bit in ccon t o generate an interrupt. ecf = 0 disables the interrupt . there are three additional bits in the cmod sfr. cild allows the pca to stop during idle mode, wdte enables and disables the watchdog function executed i n module 4, and ecf causes an interrupt when the pca timer overflows ( and the pca overflow flag cf is set ) . the ccon sfr contains the run - control bit for the pca and the flags for the pca timer overflow (cf) and each module match / capture (ccf n ). ccon(d8h) : pca counter control register bit name func tion 7 cf pca counter overflow flag. set by hardware when the counter rolls over. cf generates an interrupt if bit ecf in cmod is set. cf may be set by either hardware or software but can only be cleared by software. 6 cr pca counter run control bit. set by software to turn on the pca counter. must be cleared by software to turn the pca counter off . 5 - reserved 4 ccf4 pca module4 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 3 ccf3 pca module3 interrupt f lag. set by hardware when a match or capture occurs. must be cleared by software. 2 ccf2 pca module2 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. 1 ccf1 pca module1 interrupt flag. set by hardware when a ma tch or capture occurs. must be cleared by software. 0 ccf0 pca module0 interrupt flag. set by hardware when a match or capture occurs. must be cleared by software. t he cr bit (ccon.6) must be set by the software , and t he pca is turned off by clearing thi s bit. the cf bit (ccon.7) is set when the pca counter overflows , and an interrupt is generated if the ecf bit in the cmod register is set. the cf bit can only be cleared by software. ccon.0~ccon.4 are the flags for the modules and are set by hardware when either a match or a capture occurs. these flags can only be cleared by software. the next five sections provide more information about each of the five modes (four modes for all registers and the watchdog timer in module 4).
w78i rd2 publication release date : october 2 , 2006 - 47 - revision a 7 11.1 pca capture mode to use one o f the pca modules in capture mode , either one or both of the ccapm bits capn and capp for that module must be set. cf ccf0 ccf1 ccf2 ccf3 ccf4 - cr ccon(d8h) cexn ch cl ccapnh ccapnl - eccfn pwmn togn matn capnn cappn ecomn ccapmn, n=0~4 (dah~deh) pca timer/counter pca interrupt 0 0 0 0 capture to ccfn figure 11- 2 pca capture mode in capture mode, t he external cex n input is sampled for a transition. when a valid transition occurs , the pca hardware loads the value of the pca counter registers ch and cl into the module?s capture registers (ccapnh and ccapnl). if the ccfn (ccon) and eccfn (ccapmn) bit s are set , then an interrupt is generated.
w78i rd2 - 48 - 11.2 16- bit software timer comparator mode the pca modules can be used as software timers by setting both the ecom and mat bits in the ccapmn register . cf ccf0 ccf1 ccf2 ccf3 ccf4 - cr ccon(d8h) - eccfn pwmn togn matn capnn cappn ecomn ccapmn, n=0~4 (dah~deh) 0 0 0 write to ccapnl write to ccapnh ccapnh ccapnl ch cl pca timer/counter 16-bit comparator enable pca interrupt to ccfn match 0 0 1 figure 11- 3 pca 16 - bit timer comparator mode in this mode, t he pca timer is compared to the module?s capture registers . w hen a match occurs , an interrupt is generated if the ccfn (ccon) and eccfn (ccapmn) bits are set. 11.3 high speed output mode to activate this mode , the tog, mat, and ecom (ccapmn) bits must be set. cf ccf0 ccf1 ccf2 ccf3 ccf4 - cr ccon(d8h) - eccfn pwmn togn matn capnn cappn ecomn ccapmn, n=0~4 (dah~deh) 0 1 0 write to ccapnl write to ccapnh ccapnh ccapnl ch cl pca timer/counter 16-bit comparator enable pca interrupt to ccfn match 0 cexn 0 1 figure 11- 4 pca high speed output mod e in this mode , the cex n output toggle s each time a match occurs between the pca cou nter and the module?s capture registers.
w78i rd2 publication release date : october 2 , 2006 - 49 - revision a 7 11.4 pulse width modulator mode the pwm and ecom (ccapm) bits must be set to enable the pwm mode. enable 0 1 cexn - eccfn pwmn togn matn capnn cappn ecomn ccapmn, n=0~4 (dah~deh) pca timer/counter 0 0 0 0 ccapnh ccapnl 8-bit comparator cl 0 overflow cl < ccapnl cl >= ccapnl figure 11- 5 pac pwm mode all of the module s have the same frequency because they share the same pca timer. the duty cycle of each module , however, is independently controlled by the module?s capture register ccapln . when the value of the pca cl sfr is less than the value in ccapln , the output is l ow ; when it is equal to or greater than the value in ccapln , the output is high. when cl overflows from ff to 00, ccapln is reloaded with the value in cca p hn.
w78i rd2 - 50 - 11.5 watchdog timer the w atchdog t imer is a free - running timer that serve s as a system monitor. it is implemented in module 4 , which can still be used for other modes if the w atchdog timer is not needed. - eccf4 pwm4 tog4 mat4 capn4 capp4 ecom4 ccapm4(deh) 0 1 0 write to ccap4h write to ccap4l ccap4h ccap4l ch cl pca timer/counter 16-bit comparator enable match 0 1 0 cidl ecf cps0 cps1 - - - wdte cmod(d9h) x x module4 reset figure 11- 6 pca watchdog timer mode the program first loads a 16 - bit value in to the compare registers. then, like the other compare modes, this 16 - bit value is compared to the pca timer value. if a match occur s , an internal reset is generated , but it does not make the rst pin go high.
w78i rd2 publication release date : october 2 , 2006 - 51 - revision a 7 12. hardware watchdog ti mer (one - time enabled w ith reset - out) the wdt is intended as a way to recover whe n the cpu may be subject to software problem . the wdt consists of a 14 - bit counter and the wdt reset (wdtrst) register locat ed at 0a6h. the wdt is disabled at reset. to enable the wdt, user must wri te 01eh and 0e1h in sequence to wdtrst. once the wdt is enabled, it increment s every machine cycle , while the oscillator is running , and there is no way to disable the wdt except through reset (either hardware reset or wdt overflow reset). t he program must reset the counter by writing 01eh and 0e1h to wdtrst before the wdt counter reaches 3fffh (i.e., overflows). if it does overflow, it drive s a high pulse on the rst - pin. this pulse width is 98 source clocks in 12 - clock mode or 49 source clocks in 6 - clock m ode. no external pull - down resistor or pull - up capacitor is required on the reset pin. the wdt counter cannot be read or written. to make the best use of the wdt, the wdt should be reset in sections of code that are periodically executed in time to prevent a wdt reset. 13. dual dptr the dual dptr structure is the way the chip specif ies the address of an external data memory location. there are two 16 - bit dptr registers that address external memory . the dps bit ( auxr1 , bit 0 ) switch es between them , and it can b e toggled quickly by an inc auxr1 instruction. (auxr1, b it 2 cannot be written and is always read as a zero , so the inc auxr1 instruction does not affect the gf2 bit that is higher in the auxr1 register . ) it is important to keep track of the value of the d ps bit. for example, procedures and functions should save the dps bit before switch ing between dptr0 and dptr1 and restore the original value afterwards to prevent other code from using the wrong memory .
w78i rd2 - 52 - 14. timed - access protection the w78ird2 has features li ke timer clock selecting by setting ckcon, software reset and isp function that are crucial to the proper operation of the system. consequently, the sfr chpcon and ckcon, which control the functions, have restricted write access to protect cpu from errant operation. t he w7 8ird2 provides has a timed - access protection scheme that controls write access to critical bits. in this scheme , protected bits have a timed write - enable window. a write is successful only if this window is active ; otherwise , the write is discarded. the write - enable window is opened in two steps. first, the software writes 87 h to the register chpenr. this starts a counter , which expires in three machine cycles. then, i f the software write s 59h to chpenr before the counter expires , the write - enable window is opened for three machine cycles. after three machine cycles, the window automatically closes , and the procedure must be repeated again to access protected bits. the suggested code for opening the write - enable window is chpenr reg 0 f6 h ; d efine new register chpenr , located at 0 f6 h mov chpenr, #87h mov chpenr, #59h five e xamples , some correct and some incorrect, of using timed - access protection are shown below. example 1: valid access mov chpenr, #87h ; 3 m/ c, note: m/c = machine c ycles mov chpenr, #59h ; 3 m/c mov ck con, #00h ; 3 m/c example 2: valid access mov chpenr, #87h ; 3 m/c mov chpenr, #59h ; 3 m/c nop ; 1 m/c setb ewt ; 2 m/c example 3: valid access mov chpenr, #87h ; 3 m/c mov chpe nr, #59h ; 3 m/c orl ck con, # 01h ; 3m/c
w78i rd2 publication release date : october 2 , 2006 - 53 - revision a 7 example 4: invalid access mov chpenr, #87h ; 3 m/c mov chpenr, #59h ; 3 m/c nop ; 1 m/c nop ; 1 m/c clr md ; 2 m/c example 5: invalid access mov chpenr, #87h ; 3 m/c nop ; 1 m/c mov chpenr, #59h ; 3 m/c setb md ; 2 m/c in the first three examples, the protected bits are written before the window closes. in example 4 , however, the writ e occurs after the window has closed, so there is no change in the prote cted bit. in example 5 , the second write to chpenr occurs four machine cycles after the first write, so the timed access window in not opened at all, and the write to the protected bit fails.
w78i rd2 - 54 - 15. in - system programming ( isp) mode the w78ird2 is equip ped with 64 k b of main f lash eprom (ap flash ep rom) for the application program and 4 k b of auxiliary f lash eprom (ld flash ep rom) for the loader program. in normal operation, the microcontroller executes the code in the ap flash ep rom. if the code in the ap flash ep rom needs to be modified, however, the w78ird2 allows the program to activate the in - system programming (isp) mode to modify it. the contents in the ap flash eprom can be modified by setting the chpcon register. the chpcon is read - only by default . the pr ogram must write two specific values , 87h and then 59h , sequentially to the chpenr register to enable the chpcon write attribute. writing chpenr register with any other values disables the write attribute. setting the bit chpcon.0 makes the w78ird2 enter i sp mode when it wak es up from the next idle mode. it takes time to set this up in idle mode, however, so the program may use a timer interrupt to wake up the w78ird2 and enter isp mode after an appropriate amount of time in idle mode . to change the content s in the ap flash ep rom, the existing contents must set the chpcon register and then enter idle mode . when the w78ird2 wakes up, it switches from ap flash eprom to ld flash eprom, clears the program counter, pushing 0000h to the first 2 bytes of stack memo ry and executes the interrupt service routine in the ld flash eprom. therefore, the first execution of reti instruction will make the program jump to 00h in the ld flash eprom. when the ap flash eprom has been updated, t he w78ird2 offers a software reset t o switch back to the ap flash ep rom. setting chpcon bit s 0, 1 and 7 to logic - 1 creates a software reset to reset the cpu . a flowchart for the ld flash eprom program is shown at the end of this section. sfrah, sfral: the objective address of the on- chip f la sh eprom in isp mode. sfrfah contains the high - order byte, and sfrfal contains the low - order byte. sfrfd: the program data in isp mode . sfrcn: the control byte for isp mode. sfrcn (c7) bit name function 7 - reserve. 6 wfwin on - chip f lash eprom bank selec t for in - system programming. 0: 64 - k b f lash eprom bank is the destination for re - programming. 1: 4 - k b f lash eprom bank is the destination for re - programming. 5 oen flash eprom output enable. 4 cen flash eprom chip enable. 3, 2, 1, 0 ctrl[3:0] f lash epro m control signals ; see below.
w78i rd2 publication release date : october 2 , 2006 - 55 - revision a 7 mode wfwin ctrl<3:0> oen cen sfrah, sfral sfrfd erase 64kb ap flash ep rom 0 0010 1 0 x x program 64kb ap flash ep rom 0 0001 1 0 address in data in read 64kb ap flash ep rom 0 0000 0 0 address in data out erase 4kb ld fl ash ep rom 1 0010 1 0 x x program 4kb ld flash ep rom 1 0001 1 0 address in data in read 4kb ld flash ep rom 1 0000 0 0 address in data out
w78i rd2 - 56 - start the algorithm of in-system programming enter in-system programming mode ? (conditions depend on user's application) setting control registers mov chpenr,#87h mov chpenr,#59h mov chpcon,#03h setting timer (about 1.5 us) and enable timer interrupt start timer and enter idle mode. (cpu will be wakened from idle mode by timer interrupt, then enter in-system programming mode) execute the normal application program no yes end cpu will be wakened by interrupt and re-boot from 4kb ldrom to execute the loader program. go part 1:aprom procedure of entering in-system programming mode figure 15- 1 the algorithm of isp for ap rom
w78i rd2 publication release date : october 2 , 2006 - 57 - revision a 7 part 2: 4kb ldrom procedure of updating the 64kb aprom go timer interrupt service routine: stop timer & disable interrupt is f04kboot mode? (chpcon.7=1) reset the chpcon register: mov chpenr,#87h mov chpenr,#59h mov chpcon,#03h no yes setting timer and enable timer interrupt for wake-up . (15 ms for erasing operation) setting erase operation mode: mov sfrcn,#22h (erase 64kb aprom) start timer and enter idle mode. (erasing...) end of erase operation. cpu will be wakened by timer interrupt. pgm pgm setting timer and enable timer interrupt for wake-up . (50us for program operation) end of programming ? get the parameters of new code (address and data bytes) through i/o ports, uart or other interfaces. is currently in the f04kboot mode ? setting control registers for programming: mov sfrah,#address_h mov sfral,#address_l mov sfrfd,#data mov sfrcn,#21h software reset cpu and re-boot from the 64kb aprom. mov chpenr,#87h mov chpenr,#59h mov chpcon,#83h end executing new code from address 00h in the 64kb aprom. hardware reset to re-boot from new 64 kb aprom. (s/w reset is invalid in h/w reboot mode) yes no yes no figure 15- 2 the algorithm of isp for ld rom
w78i rd2 - 58 - 16. h/w reboot mode (boo t from ldrom) by default, the w78ird2 boots up from the ap flash ep rom after a power - on reset. sometimes, this is not desirable. h /w reboot mode force s the w78ird2 to use the ld flash ep rom instead and execute in - system programming procedure s . enter h/w reboot mode using these settings. h/w reboot mode p4.3 p2.7 p2.6 option bit mode x l l bit4 = l h/w reboot l x x bit5 = l h/w rebo ot this might be implemented by connecting pins p2.6 and p2.7 to switches or jumpers. for example , in a cd - rom system, p2.6 and p2.7 might be connected to the play and eject buttons on the panel. if the user wants to enter h/w reboot mode, the u ser can pr ess these two buttons at the same time and then turn on the power to force the w78ird2 to enter h/w reboot mode. after the power - on, releas ing both buttons finish es the in - system programming procedure. this mode can be accidentally activated, so be careful with the values of pins p2, p3, ale, ea and psen at reset . the reset timing for entering h/w reboot mode 1 p2.7 p2.6 rst 10us 20ms hi-z hi-z h/w reboot mode 2 p4.3 rst 10us 20ms hi-z figure 16- 1
w78i rd2 publication release date : october 2 , 2006 - 59 - revision a 7 17. option b its register in the on - chip flash eprom writer programming mod e mode, the f lash eprom can be programmed and verified repeatedly. until the code is ready , it can be protected by properly setting option bits. option bits control the initial configuration of w78ird2 , including code protection, system clock mode selectio n (6t/12t), h/w reboot mode selection and oscillator control. 64kb flash eprom program memory ap flash eprom 4kb flash eprom program memory ld flash eprom 0000h ffffh 0fffh reserved option bits register option bits b0 d7 d6 d5 d4 d3 d2 d1 d0 b0: lock bit, logic 0 is active b1: movc inhibit, logic 0 is active b2: encryption bit , logic 0 is active b3: logic 1 is 12 clock per machine cycle logic 0 is 6 clock per machine cycle b4: enable p2 .7 and p 2.6 as h /w reboot function logic 1: p2 .7 and p2. 6 are as i/o function logic 0: p2.7 and p 2.6 are as h/w reboot function b5: enable p 4.3 as h/ w reboot function logic 1: p 4.3 is as i /o function logic 0: p4.3 is as h/ w reboot function b6: reserved (0) b7: logic 1: the crystal frequency is above 25mhz logic 0: the crystal frequency is under 25mhz default 1 is for all security bits. the reserved bit must be kept in logic 1. option bits register b1 b2 b3 b4 b5 b6 b7 lock bit this bit is used to protect the code in the w78ird2 . it may be set after the programmer finishes programming and verifies the sequence. once this bit is s et to logic - 0, both the flash eprom data and option bits register cannot be accessed again. movc inhibit this bit is used to restrict the accessible region of the movc instruction. it can prevent a movc instruction in external program memory from reading t he internal program code. when this bit is set to logic - 0, a movc instruction in external program memory space can only access code in external memory, not in internal memory. a movc instruction in internal program memory can always access both internal an d external memory. if this bit is logic - 1, there are no restrictions on movc. encryption this bit is used to enable and disable the encryption logic for code protection. once encryption is enabled, the data presented on port 0 is encoded via encryption log ic. this bit can be reset only by erasing the whole chip. oscillator control t he gain of the on- chip oscillator amplifier can be reduced by bit b7 in the option bits register. if bit 7 is set to zero , the gain is cut in half . according the circuit in figure 20- 1 , t he value s of r , c1 and c2 may need some adjustment when running at lower gain. furthermore, reducing the gain by one - half may improperly affect an external crystal running at frequenc ies above 2 0 mhz.
w78i rd2 - 60 - 18. electrical characte ristics 18.1 a bsolute m aximum r atings parameter symbol min. max. unit dc power supply v dd ? v ss - 0.3 +6.0 v input voltage v in v ss - 0.3 v dd +0.3 v operating temperature t a - 40 85 c storage temperature t st - 55 +150 c note: exposure to conditions beyond tho se listed under absolute maximum ratings may adversely affect the life and reliability of the device. 18.2 d.c. c haracteristics (v ss = 0v, t a = 25 c, unless otherwise specified.) symbol parameter specification test conditions min. max. unit v dd operating voltage 2.7 5.5 v i dd operating current - 20 ma no load v dd = 5.5v, fosc = 20 mhz 5 ma no load v dd = 2.7v, fosc = 12 mhz i idle idle current - 9 ma v dd = 5.5v, fosc = 20 mhz 1.8 ma v dd = 2.7v, fosc = 12 mhz i pwdn power down current - 10 a v dd = 5.5v, fosc = 20 mhz - 10 a v dd = 2.7v, fosc = 12 mhz i in1 input current p1, p2, p3, p4 - 50 +10 a v dd = 5.5v or 2.7v, v in = 0v or v dd i in2 input current rst - 10 +150 a v dd = 5.5v, 0 w78i rd2 publication release date : october 2 , 2006 - 61 - revision a 7 d.c. electrical characteristics , continued symbol pa rameter specification test conditions min. max. unit v il1 input low voltage p0, p1, p2, p3, p4, rst, ea 0 0.8 v v dd = 4.5v 0 0.5 v v dd = 2.7v v il3 input low voltage xtal1 [*4] 0 0.8 v v dd = 4.5v 0 0.4 v v dd = 2.7v v ih1 input hi gh voltage p0, p1, p2, p3, p4, ea 2.4 v dd +0.2 v v dd = 5.5v 1.8 v dd +0.2 v v dd = 2.7v v ih2 input high voltage rst 3.5 v dd +0.2 v v dd = 5.5v 2.0 v dd +0.2 v v dd = 2.7v v ih3 input high voltage xtal1 [*4] 3.5 v dd +0.2 v v dd = 5.5v 1.8 v dd +0.2 v v dd = 2.7v v ol output low voltage p1, p2, p3, p4, p0, ale, psen - 0.45 v v dd = 4.5v - 0.4 v v dd = 2.7v isk1 sink current p1, p3, p4 4 8 ma v dd = 4.5v, v ol = 0.45v 2.8 5 ma v dd = 2.7v, v ol = 0.4v isk2 sink current p0, p2, al e, psen 12 18 ma v dd = 4.5v, v ol = 0.45v 5 9 ma v dd = 2.7v, v ol = 0.4v v oh output high voltage p1, p2, p3, p4, p0, ale, psen 2.4 - v v dd = 4.5v 1.4 - v v dd = 2.7v isr1 source current p1, p2, p3, p4 - 400 - 230 a v dd = 4.5v, v oh = 2.4v - 80 - 40 a v dd = 2.7v, v oh = 1.4v isr2 source current p0, p2, ale, psen - 12 - 6 ma v dd = 4.5v, v oh = 2.4v - 6 - 3 ma v dd = 2.7v, v oh = 1.4v notes: *1. rst pin is a schmitt - trigger input. * 2 . p0, ale and psen are tested in external - access mode. * 3 . xtal1 is a cmos input. * 4 . pins of p1, p2, p3 and p4 can source a transition current when they are being externally driven from 1 to 0. the transition current reaches its maximum value when v in is approximatel y 2v .
w78i rd2 - 62 - 18.3 a . c . c haracteristics the ac specifications are a function of the particular process used to manufacture the part, the ratings of the i/o buffers, the capacitive load, and the internal routing capacitance. most of the specifications can be expressed in terms of multiple input clock periods (t cp ), and actual parts will usually experience less than a 20 ns variation. clock input waveform t t xtal1 f ch cl op, t cp parameter symbol min. typ. max. unit notes operating speed fop 0 - 2 0 mhz 1 clock period t cp 25 - - n s 2 clock high t ch 10 - - n s 3 clock low t cl 10 - - n s 3 notes: 1. the clock may be stopped indefinitely in either state. 2. the t cp specification is used as a reference in other specifications. 3. there are no duty cyc le requirements on the xtal1 input. program fetch cycle parameter symbol min. typ. max. unit notes address valid to ale low t aas 1 t cp - ? - - n s 4 address hold from ale low t aah 1 t cp - ? - - n s 1, 4 ale low to psen low t apl 1 t cp - ? - - n s 4 psen low to data valid t pda - - 2 t cp n s 2 data hold after psen high t pdh 0 - 1 t cp n s 3 data float after psen high t pdz 0 - 1 t cp n s ale pulse width t alw 2 t cp - ? 2 t cp - n s 4 psen pulse width t psw 3 t cp - ? 3 t cp - n s 4 notes : 1. p0.0 ? p0.7, p2.0 ? p2.7 remain stable throu ghout entire memory cycle. 2. memory access time is 3 t cp . 3. data have been latched internally prior to psen going high. 4. " ? " (due to buffer driving delay and wire loading) is 20 n s .
w78i rd2 publication release date : october 2 , 2006 - 63 - revision a 7 data read cycle parameter symbol min. typ. max. unit notes al e low to rd low t dar 3 t cp - ? - 3 t cp+ ? n s 1, 2 rd low to data valid t dda - - 4 t cp n s 1 data hold from rd high t ddh 0 - 2 t cp n s data float from rd high t ddz 0 - 2 t cp n s rd pulse width t drd 6 t cp - ? 6 t cp - n s 2 notes: 1. data memory access time is 8 t cp . 2. " ? " (due to buffer driving delay and wire loading) is 20 ns. data write cycle parameter symbol min. typ. max. unit ale low to wr low t daw 3 t cp - ? - 3 t cp + ? n s data valid to wr low t dad 1 t cp - ? - - n s data hold from wr high t dwd 1 t cp - ? - - n s wr pulse width t dwr 6 t cp - ? 6 t cp - n s note: " ? " (due to buffer driving delay and wire loading) is 20 ns. port access cycle parameter symbol min. typ. max. unit port input setup to ale low t pds 1 tcp - - n s port input hold from ale low t pdh 0 - - n s port output to ale t pda 1 tcp - - n s note: ports are read during s5p2, and output data becomes available at the end of s6p2. the timing data are referenced to ale, since it provides a convenient reference.
w78i rd2 - 64 - 19. timing waveforms program fetch cycle s1 xtal1 s2 s3 s4 s5 s6 s1 s2 s3 s4 s5 s6 ale port 2 a0-a7 a0-a7 data a0-a7 code t a0-a7 data code port 0 psen pdh, t pdz t pda t aah t aas t psw t apl t alw data read cycle s2 s3 s5 s6 s1 s2 s3 s4 s5 s6 s1 s4 xtal1 ale psen data a8-a15 port 2 port 0 a0-a7 rd t ddh, t ddz t dda t drd t dar
w78i rd2 publication release date : october 2 , 2006 - 65 - revision a 7 data write cycle s2 s3 s5 s6 s1 s2 s3 s4 s1 s5 s6 s4 xtal1 ale psen a8-a15 data out port 2 port 0 a0-a7 wr t t daw dad t dwr t dwd port access cycle xtal1 ale s5 s6 s1 data out t t port input t sample pda pdh pds
w78i rd2 - 66 - 20. typical application circuits 20.1 external program memory and crystal ad0 a0 a0 a0 10 a1 9 a2 8 a3 7 a4 6 a5 5 a6 4 a7 3 a8 25 a9 24 a10 21 a11 23 a12 2 a13 26 a14 27 a15 1 ce 20 oe 22 o0 11 o1 12 o2 13 o3 15 o4 16 o5 17 o6 18 o7 19 27512 ad0 d0 3 q0 2 d1 4 q1 5 d2 7 q2 6 d3 8 q3 9 d4 13 q4 12 d5 14 q5 15 d6 17 q6 16 d7 18 q7 19 oc 1 g 11 74ls373 ad0 ea 31 xtal1 19 xtal2 18 rst 9 int0 12 int1 13 t0 14 t1 15 p1.0 1 p1.1 2 p1.2 3 p1.3 4 p1.4 5 p1.5 6 p1.6 7 p1.7 8 39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 17 wr p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p2.0 p2.1 p2.2 p2.3 p2.4 p2.5 p2.6 p2.7 rd 16 psen 29 ale 30 txd 11 rxd 10 10 u 8.2 k v crystal c1 c2 r ad1 ad2 ad3 ad4 ad5 ad6 ad7 a8 ad1 ad2 ad3 ad4 ad5 ad6 ad7 gnd a1 a2 a3 a4 a5 a6 a7 a1 a2 a3 a4 a5 a6 a7 a8 a9 ad1 ad2 ad3 ad4 ad5 ad6 ad7 a10 a11 a12 a13 a14 a15 gnd a9 a10 a11 a12 a13 a14 a15 dd figure 20- 1 crystal c1 c2 r 6 mhz 47p 47p - 16 mhz 30p 30p - 2 0 mhz 15p 15p - above table shows the reference values for crystal applications. notes: 1. for c1, c2 and r components , see figure 20- 1 2. the c rystal should be as close as possible to the xtal1 and xtal2 pins on the application board.
w78i rd2 publication release date : october 2 , 2006 - 67 - revision a 7 20.2 expanded external data memory and oscillator 10 u 8.2 k v oscillator ea 31 xtal1 19 xtal2 18 rst 9 int0 12 int1 13 t0 14 t1 15 p1.0 1 p1.1 2 p1.2 3 p1.3 4 p1.4 5 p1.5 6 p1.6 7 p1.7 8 p0.0 39 p0.1 38 p0.2 37 p0.3 36 p0.4 35 p0.5 34 p0.6 33 p0.7 32 p2.0 21 p2.1 22 p2.2 23 p2.3 24 p2.4 25 p2.5 26 p2.6 27 p2.7 28 rd 17 wr 16 psen 29 ale 30 txd 11 rxd 10 ad0 ad1 ad2 ad3 ad4 a d5 ad6 ad7 ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 a0 a1 a2 a3 a4 a5 a6 a7 d0 3 q0 2 d1 4 q1 5 d2 7 q2 6 d3 8 q3 9 d4 13 q4 12 d5 14 q5 15 d6 17 q6 16 d7 18 q7 19 oc 1 g 11 74ls373 a0 a1 a2 a3 a4 a5 a6 a7 10 9 8 7 6 5 4 3 a0 a1 a2 a3 a4 a5 a6 a7 ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 11 12 13 15 16 17 18 19 d0 d1 d2 d3 d4 d5 d6 d7 a8 a9 a10 a11 a12 a13 a14 25 24 21 23 26 1 20 2 a8 a9 a10 a11 a12 a13 a14 ce gnd a8 a9 a10 a11 a12 a13 a14 gnd 22 27 oe wr 20256 dd v dd figure 20- 2
w78i rd2 - 68 - 21. package dimensions 40- pin dip seating plane 1. dimension d max. & s include mold flash or tie bar burrs. 2. dimension e1 does not include interlead flash. 3. dimension d & e1 include mold mismatch and are determined at the mold parting line. 6. general appearance spec. should be based on final visual inspection spec. . 1.372 1.219 0.054 0.048 notes: symbol min. nom. max. max. nom. min. dimension in inch dimension in mm 0.050 1.27 0.210 5.334 0.010 0.150 0.016 0.155 0.018 0.160 0.022 3.81 0.406 0.254 3.937 0.457 4.064 0.559 0.008 0.120 0.670 0.010 0.130 0.014 0.140 0.203 3.048 0.254 3.302 0.356 3.556 0.540 0.550 0.545 13.72 13.97 13.84 17.01 15.24 14.986 15.494 0.600 0.590 0.610 2.286 2.54 2.794 0.090 0.100 0.110 a b c d e a l s a a 1 2 e b 1 1 e e 1 a 2.055 2.070 52.20 52.58 0 15 0.090 2.286 0.650 0.630 16.00 16.51 protrusion/intrusion. 4. dimension b1 does not include dambar 5. controlling dimension: inches. 15 0 e a a a c e base plane 1 a 1 e l a s 1 e d 1 b b 40 21 20 1 2 44- pin plcc 44 40 39 29 28 18 17 7 6 1 l c 1 b 2 a h d d e b e h e y a a 1 seating plane d g g e symbol min. nom. max. max. nom. min. dimension in inch dimension in mm a b c d e h e l y a a 1 2 e b 1 h d g g d e notes: on final visual inspection spec. 4. general appearance spec. should be based 3. controlling dimension: inches protrusion/intrusion. 2. dimension b1 does not include dambar flash. 1. dimension d & e do not include interlead 0.020 0.145 0.026 0.016 0.008 0.648 0.590 0.680 0.090 0.150 0.028 0.018 0.010 0.653 0.610 0.690 0.100 0.050 bsc 0.185 0.155 0.032 0.022 0.014 0.658 0.630 0.700 0.110 0.004 0.508 3.683 0.66 0.406 0.203 16.46 14.99 17.27 2.296 3.81 0.711 0.457 0.254 16.59 15.49 17.53 2.54 1.27 4.699 3.937 0.813 0.559 0.356 16.71 16.00 17.78 2.794 0.10 bsc 16.71 16.59 16.46 0.658 0.653 0.648 16.00 15.49 14.99 0.630 0.610 0.590 17.78 17.53 17.27 0.700 0.690 0.680
w78i rd2 publication release date : october 2 , 2006 - 69 - revision a 7 44- pin pqfp seating plane 11 22 12 see detail f e b a y 1 a a l l 1 c e e h 1 d 44 h d 34 33 detail f 1. dimension d & e do not include interlead flash. 2. dimension b does not include dambar protrusion/intrusion. 3. controlling dimension: millimeter 4. general appearance spec. should be based on final visual inspection spec. 0.254 0.101 0.010 0.004 notes: symbol min. nom. max. max. nom. min. dimension in inch dimension in mm a b c d e h d h e l y a a l 1 1 2 e 0.006 0.152 --- 0.002 0.075 0.01 0.081 0.014 0.087 0.018 1.90 0.25 0.05 2.05 0.35 2.20 0.45 0.390 0.025 0.063 0.003 0 7 0.394 0.031 0.398 0.037 9.9 0.80 0.65 1.6 10.00 0.8 10.1 0.95 0.398 0.394 0.390 0.530 0.520 0.510 13.45 13.2 12.95 10.1 10.00 9.9 7 0 0.08 0.031 0.01 0.02 0.25 0.5 --- --- --- --- --- 2 0.025 0.036 0.635 0.952 0.530 0.520 0.510 13.45 13.2 12.95 0.051 0.075 1.295 1.905
w78i rd2 - 70 - 22. application note 22.1 in -s ystem programming (isp) software examples this application note illustrates the in - system programmability of the winbond w78ird2 flash eprom microcontroller. in this example, the microcontroller boot s from 64 kb ap flash ep rom bank and wait s for a key to enter isp mode to re - program the 64- kb ap flash ep rom. while in isp mode, the microcontroller executes the loader program in the 4 - kb ld flash ep rom. the loader program erases the 64 - kb ap flash ep rom and then reads the new code from an external sram buffer (or through other interfaces) to update the 64 - kb ap flash ep rom. example 1: ;************************************************* ****************************************************************** ;* example of 64k ap flash ep rom program: program will scan the p1.0. i f p1.0 = 0, enters ;* in - system programming mode for updating the content of ap flash ep rom code else executes the ;* current rom code. ;* xtal = 40 mhz ;******************************************************************************************************************* .chip 8052 .ramchk off .symbols chpcon equ bfh chpenr equ f6h sfral equ c4h sfrah equ c5h sfrfd equ c6h sfrcn equ c7h org 0h ljmp 100h ; jump to main program ;************************************************************************ ;* timer0 service vector org = 000bh ;************************************************************************ org 00bh clr tr0 ; tr0 = 0, stop timer0 mov tl0, r6 mov th0, r7 reti ;************************************************************************ ;* 6 4k ap flash ep rom main program ;************************************************************************ org 100h main_64k: mov a, p1 ; scan p1.0 anl a, #01h cjne a, #01h, program_64k ; if p1.0 = 0, enter in - system programming mode jmp normal_mode program_64k: mov chpenr, #87h ; chpenr = 87h, chpcon register wrte enable mov chpenr, #59h ; chpenr = 59h, chpcon register write enable mov chpcon, #03h ; ch pcon = 03h, enter in - system programming mode mov tcon, #00h ; tr = 0 timer0 stop mov ip, #00h ; ip = 00h mov ie, #82h ; timer0 interrupt enable for wake - up from idle mode
w78i rd2 publication release date : october 2 , 2006 - 71 - revision a 7 mov r6, #f0h ; tl0 = f0h mov r7, #ffh ; th0 = ffh mov tl0, r6 mov th0, r7 mov tmod, #01h ; tmod = 01h, set timer0 a 16 - bit timer mov tcon, #10h ; tcon = 10h, tr0 = 1, go mo v pcon, #01h ; enter idle mode for launching the in- system ; programmability ;******************************************************************************** ;* normal mo de 64kb ap flash ep rom program: depending use r's application ;******************************************************************************** normal_mode: . ; user's application program . . . example 2: ;******************************************************************* ********************************************************** ;* example of 4kb ld flash ep rom program: this lo a der program will erase the 64kb ap flash ep r om first, ;* then reads the new code from external sram and program them into 64kb ap flash ep rom bank. ;* xtal = 40mhz ;**************************************************************************************************************************** * .chip 8052 .ramchk off .symbols chpcon equ bfh chpenr equ f6h sfral equ c4h sfrah equ c5h sfrfd equ c6h sfrcn equ c7h org 000h ljmp 100h ; jump to main program ;************************************************************************ ;* 1. timer0 service vector org = 0bh ;************************************************************************ org 000bh clr tr0 ; tr0 = 0, stop timer0 mov tl0, r6 mov th0, r7 reti ;************************************************************************ ;* 4kb ld flash ep rom main program ;************************************************************************ org 100h main_4k: mov sp, #c0h ; be initial sp register mov chpenr, #87h ; chpenr = 87h, chpcon write enable. mov ch penr, #59h ; chpenr = 59h, chpcon write enable. mov a, chpcon
w78i rd2 - 72 - anl a, #80h cjne a, #80h, update_64k; check h/w reboot mode ? mov chpcon, #03h ; chpcon = 03h, enable in- system programming. mov chpenr, #00h ; disab le chpcon write attribute mov tcon, #00h ; tcon = 00h, tr = 0 timer0 stop mov tmod, #01h ; tmod = 01h, set timer0 a 16bit timer mov ip, #00h ; ip = 00h mov ie, #82h ; ie = 82h, timer0 interrupt enabled mov r6, #f0h mov r7, #ffh mov tl0, r6 mov th0, r7 mov tcon, #10h ; tcon = 10h, tr0 = 1, go mov pcon, #01h ; enter idle mode update_64k: mov chpenr, #00h ; disable chpcon write - attribute mov tcon, #00h ; tcon = 00h, tr = 0 tim0 stop mov ip, #00h ; ip = 00h mov ie, #82h ; ie = 82h, timer0 interrupt enabled mov tmod, #01h ; tmod = 01h, mode1 mov r6, #3ch ; set wake - up time for erase opera tion, about 15 m s . depending ; on user's system clock rate. mov r7, #b0h mov tl0, r6 mov th0, r7 erase_p_4k: mov sfrcn, #22h ; sfrcn(c7h) = 22h erase 64k mov tcon, #10h ; tcon = 10h, tr0 = 1, go mov pcon, #01h ; enter idle mode (for erase operation) ;********************************************************************* ;* blank check ;********************************************************************* mov sfrcn, #0h ; re ad 64kb ap flash ep ro m mode mov sfrah, #0h ; start address = 0h mov sfral, #0h mov r6, #fbh ; set timer for read operation, about 1.5 s. mov r7, #ffh mov tl0, r6 mov th0, r7 blank_check_loop: se tb tr0 ; enable timer 0 mov pcon, #01h ; enter idle mode mov a, sfrfd ; read one byte cjne a, #ffh, blank_ check_error inc sfral ; next address mov a, sfral jnz blank_check_loop inc sfrah mov a, sfrah cjne a, #0h, b lank_check_loop ; end address = ffffh jmp program_64krom
w78i rd2 publication release date : october 2 , 2006 - 73 - revision a 7 blank_check_error: mov p1, #f0h mov p3, #f0h jmp $ ;*************** **************************************************************** ;* re - programming 64kb ap flash ep rom bank ;******************************************************************************* program_64krom: mov dptr, #0h ; the address of new rom code mov r2, #00h ; target low byte ad dress mov r1, #00h ; ta rget high byte addre ss mov dptr, #0h ; external sram buff er address mov sfrah, r1 ; sfrah, target high address mov sfrcn, #21h ; sfrcn(c7h) = 21 (p rogram 64k) mov r6, #5ah ; set timer for prog ramming, about 50 s. mov r7, #ffh mov tl0, r6 mov th0, r7 prog_d_64k: mov sfral, r2 ; sfral(c4h) = low b yte address movx a, @dptr ; read data from ext ernal sram buffer mov sfrfd, a ; sfrfd(c6h) = data in mov tcon, #10h ; tcon = 10h, tr0 = 1, go mov pcon, #01h ; enter idle mode (p rorgamming) inc dptr inc r2 cjne r2, #0h, prog_d _64k inc r1 mov sfrah, r1 cjne r1, #0h, prog_d_64k ;***************** ************************************************************ ; * verify 64kb ap flash ep rom bank ;******************* ********************************************************** mov r4, #03h ; error counter mov r6, #fbh ; set time r for read verify, about 1.5 s. mov r7, #ffh mov tl0, r6 mov th0, r7 mov dptr, #0h ; the start address of sample code mov r2, #0h ; target low byte address mov r1, #0h ; target high byte address mov sfrah, r1 ; sfrah, target high address mov sfrcn, #00h ; sfrcn = 00 (read rom code) read_verify_64k: mov sfral, r2 ; sfral(c4h) = low address mov tcon, #10h ; tcon = 10h, tr0 = 1, go mov pcon, #01h inc r2 movx a, @dptr inc dptr cjne a, sfrfd, error_64k cjne r2, #0h, read_verify_64k
w78i rd2 - 74 - inc r1 mov sfrah, r1 cjne r1, #0h, read_verify_64k ;****************************************** ************************************ ;* programming completly, software reset cpu ;****************************************************************************** mov chpenr, #87h ; chpenr = 87h mov chpenr, #59h ; chpenr = 59h mov chpcon, #83h ; chpcon = 83h, software reset. error_64k: djnz r4, update_64k ; if error occurs, repeat 3 times. . ; in - system programming fail, user's process to deal with it. . . . 22.2 how to use p rogrammable counter array please go to winbond ? s website at http://www.winbond.com.tw for t the application note.
w78i rd2 publication release date : october 2 , 2006 - 75 - revision a 7 23. r e v i sion history version date page description a 1 june 2004 - initial issued a2 august 2004 38 modify the content of pca 74 add the application of pca a3 sep. 30, 2004 38 add enhanced full duplex serial port with framing error detection and automatic address recognition a4 april 20, 2005 72 add important notice a5 june 2 , 2005 4 17 22 38 to add lead free part no. of packages. correct gf3 to gf2 in auxr1 correct xiconh add programmable timers/counters. a6 sep. 5 , 2005 - 50 re - organi ze document . add a section of timed - access protection. a7 october 2 , 2006 remove block diagram change operating frequency into 20mhz 3 remove all leaded parts
w78i rd2 - 76 - important notice nuvoton products are neither intended nor warranted for usage in systems or equipment, any malfunction or failure of which may cause loss of human life, bodily injury or severe property damage. such applications are deemed , ?insecure usage?. insecure usage includes, but is not limited to: equipment for surgical implementation, atomic energy control instruments, airplane or sp aceship instruments, the control or operation of dynamic, brake or safety systems designed for vehicular use, traffic signal instruments, all types of safety devices, and other applications intended to support or sustain life. all insecure usage shall be made at customer?s risk, and in the event that third parties lay claims to nuvoton as a result of customer?s insecure usage, customer shall indemnify the damages and liabilities thus incurred by nuvoton.


▲Up To Search▲   

 
Price & Availability of W78IRD2A25DL

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X